|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
using System.ServiceProcess;
|
|
|
|
|
using System;
|
|
|
|
|
using System.ServiceProcess;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
|
|
|
using NzbDrone.Common.Processes;
|
|
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
|
using NzbDrone.Core.Lifecycle;
|
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
@ -22,10 +24,17 @@ namespace NzbDrone.Host
|
|
|
|
|
private readonly PriorityMonitor _priorityMonitor;
|
|
|
|
|
private readonly IStartupContext _startupContext;
|
|
|
|
|
private readonly IBrowserService _browserService;
|
|
|
|
|
private readonly IProcessProvider _processProvider;
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
public NzbDroneServiceFactory(IConfigFileProvider configFileProvider, IHostController hostController,
|
|
|
|
|
IRuntimeInfo runtimeInfo, PriorityMonitor priorityMonitor, IStartupContext startupContext, IBrowserService browserService, Logger logger)
|
|
|
|
|
public NzbDroneServiceFactory(IConfigFileProvider configFileProvider,
|
|
|
|
|
IHostController hostController,
|
|
|
|
|
IRuntimeInfo runtimeInfo,
|
|
|
|
|
PriorityMonitor priorityMonitor,
|
|
|
|
|
IStartupContext startupContext,
|
|
|
|
|
IBrowserService browserService,
|
|
|
|
|
IProcessProvider processProvider,
|
|
|
|
|
Logger logger)
|
|
|
|
|
{
|
|
|
|
|
_configFileProvider = configFileProvider;
|
|
|
|
|
_hostController = hostController;
|
|
|
|
@ -33,6 +42,7 @@ namespace NzbDrone.Host
|
|
|
|
|
_priorityMonitor = priorityMonitor;
|
|
|
|
|
_startupContext = startupContext;
|
|
|
|
|
_browserService = browserService;
|
|
|
|
|
_processProvider = processProvider;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -43,6 +53,11 @@ namespace NzbDrone.Host
|
|
|
|
|
|
|
|
|
|
public void Start()
|
|
|
|
|
{
|
|
|
|
|
if (OsInfo.IsLinux)
|
|
|
|
|
{
|
|
|
|
|
Console.CancelKeyPress += (sender, eventArgs) => _processProvider.Kill(_processProvider.GetCurrentProcess().Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_runtimeInfo.IsRunning = true;
|
|
|
|
|
_hostController.StartServer();
|
|
|
|
|
|
|
|
|
@ -75,6 +90,11 @@ namespace NzbDrone.Host
|
|
|
|
|
|
|
|
|
|
public void Handle(ApplicationShutdownRequested message)
|
|
|
|
|
{
|
|
|
|
|
if (OsInfo.IsLinux)
|
|
|
|
|
{
|
|
|
|
|
_processProvider.Kill(_processProvider.GetCurrentProcess().Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!_runtimeInfo.IsWindowsService && !message.Restarting)
|
|
|
|
|
{
|
|
|
|
|
Shutdown();
|
|
|
|
|