mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-23 14:55:20 -07:00
This commit is contained in:
parent
964c18b236
commit
b82f2376a7
2 changed files with 18 additions and 5 deletions
|
@ -88,11 +88,15 @@ namespace Radarr.Host
|
||||||
{
|
{
|
||||||
var instancePolicy = _container.Resolve<ISingleInstancePolicy>();
|
var instancePolicy = _container.Resolve<ISingleInstancePolicy>();
|
||||||
|
|
||||||
if (isService)
|
if (startupContext.Flags.Contains(StartupContext.TERMINATE))
|
||||||
{
|
{
|
||||||
instancePolicy.KillAllOtherInstance();
|
instancePolicy.KillAllOtherInstance();
|
||||||
}
|
}
|
||||||
else if (startupContext.Flags.Contains(StartupContext.TERMINATE))
|
else if (startupContext.Args.ContainsKey(StartupContext.APPDATA))
|
||||||
|
{
|
||||||
|
instancePolicy.WarnIfAlreadyRunning();
|
||||||
|
}
|
||||||
|
else if (isService)
|
||||||
{
|
{
|
||||||
instancePolicy.KillAllOtherInstance();
|
instancePolicy.KillAllOtherInstance();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ namespace Radarr.Host
|
||||||
{
|
{
|
||||||
void PreventStartIfAlreadyRunning();
|
void PreventStartIfAlreadyRunning();
|
||||||
void KillAllOtherInstance();
|
void KillAllOtherInstance();
|
||||||
|
void WarnIfAlreadyRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SingleInstancePolicy : ISingleInstancePolicy
|
public class SingleInstancePolicy : ISingleInstancePolicy
|
||||||
|
@ -45,6 +46,14 @@ namespace Radarr.Host
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void WarnIfAlreadyRunning()
|
||||||
|
{
|
||||||
|
if (IsAlreadyRunning())
|
||||||
|
{
|
||||||
|
_logger.Debug("Another instance of Radarr is already running.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool IsAlreadyRunning()
|
private bool IsAlreadyRunning()
|
||||||
{
|
{
|
||||||
return GetOtherNzbDroneProcessIds().Any();
|
return GetOtherNzbDroneProcessIds().Any();
|
||||||
|
@ -64,14 +73,14 @@ namespace Radarr.Host
|
||||||
|
|
||||||
if (otherProcesses.Any())
|
if (otherProcesses.Any())
|
||||||
{
|
{
|
||||||
_logger.Info("{0} instance(s) of Sonarr are running", otherProcesses.Count);
|
_logger.Info("{0} instance(s) of Radarr are running", otherProcesses.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
return otherProcesses;
|
return otherProcesses;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Warn(ex, "Failed to check for multiple instances of Sonarr.");
|
_logger.Warn(ex, "Failed to check for multiple instances of Radarr.");
|
||||||
return new List<int>();
|
return new List<int>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue