app lifecycle cleanup

This commit is contained in:
kayone
2013-11-25 21:36:06 -08:00
parent cbcbaa2305
commit 266d1a43d9
5 changed files with 50 additions and 11 deletions

View File

@@ -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 @@ namespace NzbDrone.Console
{
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);
}
}
}
}