2011-10-13 02:24:30 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.ServiceProcess;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using NLog;
|
2011-10-11 07:11:05 +00:00
|
|
|
|
using Ninject;
|
2011-10-07 01:30:44 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone
|
|
|
|
|
{
|
2011-10-13 02:24:30 +00:00
|
|
|
|
public class NzbDroneService : ServiceBase
|
2011-10-07 01:30:44 +00:00
|
|
|
|
{
|
2011-10-13 02:24:30 +00:00
|
|
|
|
|
|
|
|
|
private static readonly Logger Logger = LogManager.GetLogger("Host.CentralDispatch");
|
|
|
|
|
|
2011-10-07 01:30:44 +00:00
|
|
|
|
protected override void OnStart(string[] args)
|
|
|
|
|
{
|
2011-10-13 02:24:30 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
while (!Debugger.IsAttached) Thread.Sleep(100);
|
|
|
|
|
Debugger.Break();
|
|
|
|
|
CentralDispatch.Kernel.Get<ApplicationServer>().Start();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Logger.Fatal("Failed to start Windows Service", e);
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-07 01:30:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnStop()
|
|
|
|
|
{
|
2011-10-13 02:24:30 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CentralDispatch.Kernel.Get<ApplicationServer>().Stop();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Logger.Fatal("Failed to stop Windows Service", e);
|
|
|
|
|
}
|
2011-10-11 07:11:05 +00:00
|
|
|
|
}
|
2011-10-07 01:30:44 +00:00
|
|
|
|
}
|
2011-10-07 06:57:43 +00:00
|
|
|
|
}
|