mirror of
https://github.com/Radarr/Radarr.git
synced 2024-08-18 08:19:38 +02:00
app lifecycle cleanup
This commit is contained in:
parent
cbcbaa2305
commit
266d1a43d9
@ -6,14 +6,16 @@ public interface IStartupArguments
|
||||
{
|
||||
HashSet<string> Flags { get; }
|
||||
Dictionary<string, string> Args { get; }
|
||||
bool InstallService { get; }
|
||||
bool UninstallService { get; }
|
||||
}
|
||||
|
||||
public class StartupArguments : IStartupArguments
|
||||
{
|
||||
public const string APPDATA = "data";
|
||||
public const string NO_BROWSER = "nobrowser";
|
||||
public const string INSTALL_SERVICE = "i";
|
||||
public const string UNINSTALL_SERVICE = "u";
|
||||
internal const string INSTALL_SERVICE = "i";
|
||||
internal const string UNINSTALL_SERVICE = "u";
|
||||
public const string HELP = "?";
|
||||
|
||||
public StartupArguments(params string[] args)
|
||||
@ -40,5 +42,21 @@ public StartupArguments(params string[] args)
|
||||
|
||||
public HashSet<string> Flags { get; private set; }
|
||||
public Dictionary<string, string> Args { get; private set; }
|
||||
|
||||
public bool InstallService
|
||||
{
|
||||
get
|
||||
{
|
||||
return Flags.Contains(INSTALL_SERVICE);
|
||||
}
|
||||
}
|
||||
|
||||
public bool UninstallService
|
||||
{
|
||||
get
|
||||
{
|
||||
return Flags.Contains(UNINSTALL_SERVICE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Host;
|
||||
@ -17,21 +18,31 @@ public static void Main(string[] args)
|
||||
{
|
||||
var startupArgs = new StartupArguments(args);
|
||||
LogTargets.Register(startupArgs, false, true);
|
||||
Bootstrap.Start(startupArgs, new ConsoleAlerts());
|
||||
var container = Bootstrap.Start(startupArgs, new ConsoleAlerts());
|
||||
|
||||
if (startupArgs.InstallService || startupArgs.UninstallService)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var serviceFactory = container.Resolve<INzbDroneServiceFactory>();
|
||||
|
||||
while (!serviceFactory.IsServiceStopped)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
catch (TerminateApplicationException)
|
||||
{
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Console.WriteLine("");
|
||||
System.Console.WriteLine("");
|
||||
Logger.FatalException("EPIC FAIL!", e);
|
||||
System.Console.WriteLine("Press any key to exit...");
|
||||
System.Console.ReadLine();
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
Thread.Sleep(10 * 60);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ namespace NzbDrone.Host
|
||||
{
|
||||
public interface INzbDroneServiceFactory
|
||||
{
|
||||
bool IsServiceStopped { get; }
|
||||
ServiceBase Build();
|
||||
void Start();
|
||||
}
|
||||
@ -68,8 +69,11 @@ protected override void OnStop()
|
||||
_logger.Info("Attempting to stop application.");
|
||||
_hostController.StopServer();
|
||||
_logger.Info("Application has finished stop routine.");
|
||||
IsServiceStopped = true;
|
||||
}
|
||||
|
||||
public bool IsServiceStopped { get; private set; }
|
||||
|
||||
public ServiceBase Build()
|
||||
{
|
||||
return this;
|
||||
|
@ -101,12 +101,12 @@ private ApplicationModes GetApplicationMode()
|
||||
return ApplicationModes.Help;
|
||||
}
|
||||
|
||||
if (!OsInfo.IsLinux && _startupArguments.Flags.Contains(StartupArguments.INSTALL_SERVICE))
|
||||
if (!OsInfo.IsLinux && _startupArguments.InstallService)
|
||||
{
|
||||
return ApplicationModes.InstallService;
|
||||
}
|
||||
|
||||
if (!OsInfo.IsLinux && _startupArguments.Flags.Contains(StartupArguments.UNINSTALL_SERVICE))
|
||||
if (!OsInfo.IsLinux && _startupArguments.UninstallService)
|
||||
{
|
||||
return ApplicationModes.UninstallService;
|
||||
}
|
||||
|
@ -68,6 +68,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.SignalR.Ow
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "External", "External", "{F6E3A728-AE77-4D02-BAC8-82FBC1402DDA}"
|
||||
EndProject
|
||||
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "NzbDrone.Setup", "NzbDrone.Setup\NzbDrone.Setup.wixproj", "{F5958838-EBE5-4A76-A27F-5AFA9A8D7818}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x86 = Debug|x86
|
||||
@ -170,6 +172,10 @@ Global
|
||||
{2B8C6DAD-4D85-41B1-83FD-248D9F347522}.Debug|x86.Build.0 = Debug|x86
|
||||
{2B8C6DAD-4D85-41B1-83FD-248D9F347522}.Release|x86.ActiveCfg = Release|x86
|
||||
{2B8C6DAD-4D85-41B1-83FD-248D9F347522}.Release|x86.Build.0 = Release|x86
|
||||
{F5958838-EBE5-4A76-A27F-5AFA9A8D7818}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{F5958838-EBE5-4A76-A27F-5AFA9A8D7818}.Debug|x86.Build.0 = Debug|x86
|
||||
{F5958838-EBE5-4A76-A27F-5AFA9A8D7818}.Release|x86.ActiveCfg = Release|x86
|
||||
{F5958838-EBE5-4A76-A27F-5AFA9A8D7818}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -191,9 +197,9 @@ Global
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976} = {486ADF86-DD89-4E19-B805-9D94F19800D9}
|
||||
{95C11A9E-56ED-456A-8447-2C89C1139266} = {486ADF86-DD89-4E19-B805-9D94F19800D9}
|
||||
{D12F7F2F-8A3C-415F-88FA-6DD061A84869} = {486ADF86-DD89-4E19-B805-9D94F19800D9}
|
||||
{1B9A82C4-BCA1-4834-A33E-226F17BE070B} = {F6E3A728-AE77-4D02-BAC8-82FBC1402DDA}
|
||||
{2B8C6DAD-4D85-41B1-83FD-248D9F347522} = {F6E3A728-AE77-4D02-BAC8-82FBC1402DDA}
|
||||
{F6FC6BE7-0847-4817-A1ED-223DC647C3D7} = {F6E3A728-AE77-4D02-BAC8-82FBC1402DDA}
|
||||
{1B9A82C4-BCA1-4834-A33E-226F17BE070B} = {F6E3A728-AE77-4D02-BAC8-82FBC1402DDA}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.0\lib\NET35;packages\Unity.2.1.505.2\lib\NET35
|
||||
|
Loading…
Reference in New Issue
Block a user