1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-27 18:17:13 +00:00

Tweaked SingleInstancePolicy not to cancel startup if AppData is overridden is set

This commit is contained in:
Qstick 2017-10-28 16:35:02 -04:00
parent d6bb4c29d0
commit ba27554bd3
2 changed files with 18 additions and 5 deletions

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Reflection;
using System.Threading;
using NLog;
@ -88,11 +88,15 @@ private static void EnsureSingleInstance(bool isService, IStartupContext startup
{
var instancePolicy = _container.Resolve<ISingleInstancePolicy>();
if (isService)
if (startupContext.Flags.Contains(StartupContext.TERMINATE))
{
instancePolicy.KillAllOtherInstance();
}
else if (startupContext.Flags.Contains(StartupContext.TERMINATE))
else if (startupContext.Args.ContainsKey(StartupContext.APPDATA))
{
instancePolicy.WarnIfAlreadyRunning();
}
else if (isService)
{
instancePolicy.KillAllOtherInstance();
}

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using NLog;
@ -10,6 +10,7 @@ public interface ISingleInstancePolicy
{
void PreventStartIfAlreadyRunning();
void KillAllOtherInstance();
void WarnIfAlreadyRunning();
}
public class SingleInstancePolicy : ISingleInstancePolicy
@ -45,6 +46,14 @@ public void KillAllOtherInstance()
}
}
public void WarnIfAlreadyRunning()
{
if (IsAlreadyRunning())
{
_logger.Debug("Another instance of Lidarr is already running.");
}
}
private bool IsAlreadyRunning()
{
return GetOtherNzbDroneProcessIds().Any();
@ -76,4 +85,4 @@ private List<int> GetOtherNzbDroneProcessIds()
}
}
}
}
}