1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-26 22:46:53 -04:00

Shutdown working on mono

This commit is contained in:
markus101
2014-02-03 23:11:36 -08:00
committed by Mark McDowall
parent aa1a76fe72
commit 6ff9c9f61e
6 changed files with 43 additions and 15 deletions
+23 -3
View File
@@ -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();