diff --git a/src/NzbDrone.Common/EnvironmentInfo/AppFolderInfo.cs b/src/NzbDrone.Common/EnvironmentInfo/AppFolderInfo.cs
index 3bf7876f3..3a5bcd019 100644
--- a/src/NzbDrone.Common/EnvironmentInfo/AppFolderInfo.cs
+++ b/src/NzbDrone.Common/EnvironmentInfo/AppFolderInfo.cs
@@ -1,11 +1,6 @@
using System;
using System.IO;
using System.Reflection;
-using System.Security.AccessControl;
-using System.Security.Principal;
-using NLog;
-using NzbDrone.Common.Disk;
-using NzbDrone.Common.Instrumentation;
namespace NzbDrone.Common.EnvironmentInfo
{
diff --git a/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs b/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs
index aec416e61..314b7cb6a 100644
--- a/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs
+++ b/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.IO;
+using System.Reflection;
using System.Security.Principal;
using System.ServiceProcess;
using NLog;
@@ -15,6 +16,7 @@ namespace NzbDrone.Common.EnvironmentInfo
bool IsWindowsService { get; }
bool IsConsole { get; }
bool IsRunning { get; set; }
+ string ExecutingApplication { get; }
}
public class RuntimeInfo : IRuntimeInfo
@@ -30,6 +32,8 @@ namespace NzbDrone.Common.EnvironmentInfo
OsInfo.IsWindows &&
serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME) &&
serviceProvider.GetStatus(ServiceProvider.NZBDRONE_SERVICE_NAME) == ServiceControllerStatus.StartPending;
+
+ ExecutingApplication = Assembly.GetEntryAssembly().Location;
}
static RuntimeInfo()
@@ -73,6 +77,7 @@ namespace NzbDrone.Common.EnvironmentInfo
}
public bool IsRunning { get; set; }
+ public string ExecutingApplication { get; private set; }
public static bool IsProduction { get; private set; }
diff --git a/src/NzbDrone.Common/NzbDrone.Common.csproj b/src/NzbDrone.Common/NzbDrone.Common.csproj
index 6ce3ba94c..9378ab2f6 100644
--- a/src/NzbDrone.Common/NzbDrone.Common.csproj
+++ b/src/NzbDrone.Common/NzbDrone.Common.csproj
@@ -101,6 +101,7 @@
+
diff --git a/src/NzbDrone.Common/Processes/INzbDroneProcessProvider.cs b/src/NzbDrone.Common/Processes/INzbDroneProcessProvider.cs
new file mode 100644
index 000000000..29f16b7fa
--- /dev/null
+++ b/src/NzbDrone.Common/Processes/INzbDroneProcessProvider.cs
@@ -0,0 +1,10 @@
+using System.Collections.Generic;
+using NzbDrone.Common.Model;
+
+namespace NzbDrone.Common.Processes
+{
+ public interface INzbDroneProcessProvider
+ {
+ List GetNzbDroneProcesses();
+ }
+}
diff --git a/src/NzbDrone.Core/Lifecycle/Commands/RestartCommand.cs b/src/NzbDrone.Core/Lifecycle/Commands/RestartCommand.cs
index 6f0324c6a..82c20cc07 100644
--- a/src/NzbDrone.Core/Lifecycle/Commands/RestartCommand.cs
+++ b/src/NzbDrone.Core/Lifecycle/Commands/RestartCommand.cs
@@ -4,12 +4,5 @@ namespace NzbDrone.Core.Lifecycle.Commands
{
public class RestartCommand : Command
{
- public override bool SendUpdatesToClient
- {
- get
- {
- return true;
- }
- }
}
}
diff --git a/src/NzbDrone.Core/Lifecycle/Commands/ShutdownCommand.cs b/src/NzbDrone.Core/Lifecycle/Commands/ShutdownCommand.cs
index f1d20c46e..b0fffd8e5 100644
--- a/src/NzbDrone.Core/Lifecycle/Commands/ShutdownCommand.cs
+++ b/src/NzbDrone.Core/Lifecycle/Commands/ShutdownCommand.cs
@@ -4,12 +4,5 @@ namespace NzbDrone.Core.Lifecycle.Commands
{
public class ShutdownCommand : Command
{
- public override bool SendUpdatesToClient
- {
- get
- {
- return true;
- }
- }
}
}
diff --git a/src/NzbDrone.Core/Lifecycle/LifestyleService.cs b/src/NzbDrone.Core/Lifecycle/LifecycleService.cs
similarity index 58%
rename from src/NzbDrone.Core/Lifecycle/LifestyleService.cs
rename to src/NzbDrone.Core/Lifecycle/LifecycleService.cs
index f051e723b..25199b49f 100644
--- a/src/NzbDrone.Core/Lifecycle/LifestyleService.cs
+++ b/src/NzbDrone.Core/Lifecycle/LifecycleService.cs
@@ -1,4 +1,4 @@
-using System.IO;
+using System;
using NLog;
using NzbDrone.Common;
using NzbDrone.Common.EnvironmentInfo;
@@ -11,26 +11,23 @@ using IServiceProvider = NzbDrone.Common.IServiceProvider;
namespace NzbDrone.Core.Lifecycle
{
- public class LifestyleService: IExecute, IExecute
+ public class LifecycleService: IExecute, IExecute
{
private readonly IEventAggregator _eventAggregator;
private readonly IRuntimeInfo _runtimeInfo;
- private readonly IAppFolderInfo _appFolderInfo;
private readonly IServiceProvider _serviceProvider;
private readonly IProcessProvider _processProvider;
private readonly Logger _logger;
- public LifestyleService(IEventAggregator eventAggregator,
+ public LifecycleService(IEventAggregator eventAggregator,
IRuntimeInfo runtimeInfo,
- IAppFolderInfo appFolderInfo,
IServiceProvider serviceProvider,
IProcessProvider processProvider,
Logger logger)
{
_eventAggregator = eventAggregator;
_runtimeInfo = runtimeInfo;
- _appFolderInfo = appFolderInfo;
_serviceProvider = serviceProvider;
_processProvider = processProvider;
_logger = logger;
@@ -38,7 +35,7 @@ namespace NzbDrone.Core.Lifecycle
public void Execute(ShutdownCommand message)
{
- _logger.ProgressInfo("Shutdown requested, goodbye.");
+ _logger.Info("Shutdown requested.");
_eventAggregator.PublishEvent(new ApplicationShutdownRequested());
if (_runtimeInfo.IsWindowsService)
@@ -49,7 +46,13 @@ namespace NzbDrone.Core.Lifecycle
public void Execute(RestartCommand message)
{
- _logger.ProgressInfo("Restart requested, brb.");
+ _logger.Info("Restart requested.");
+
+ if (OsInfo.IsLinux)
+ {
+ _processProvider.SpawnNewProcess(_runtimeInfo.ExecutingApplication, "--terminateexisting --nobrowser");
+ }
+
_eventAggregator.PublishEvent(new ApplicationShutdownRequested(true));
if (_runtimeInfo.IsWindowsService)
@@ -59,26 +62,7 @@ namespace NzbDrone.Core.Lifecycle
else
{
- //TODO: move this to environment specific projects
- if (OsInfo.IsWindows)
- {
- if (_runtimeInfo.IsConsole)
- {
- //Run console with switch
- var path = Path.Combine(_appFolderInfo.StartUpFolder,
- ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME + ".exe");
-
- _processProvider.SpawnNewProcess(path, "--terminateexisting --nobrowser");
- }
-
- else
- {
- var path = Path.Combine(_appFolderInfo.StartUpFolder,
- ProcessProvider.NZB_DRONE_PROCESS_NAME + ".exe");
-
- _processProvider.Start(path, "--terminateexisting --nobrowser");
- }
- }
+ _processProvider.SpawnNewProcess(_runtimeInfo.ExecutingApplication, "--terminateexisting --nobrowser");
}
}
}
diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj
index 1944dc15a..4c85322c3 100644
--- a/src/NzbDrone.Core/NzbDrone.Core.csproj
+++ b/src/NzbDrone.Core/NzbDrone.Core.csproj
@@ -292,7 +292,7 @@
-
+
diff --git a/src/NzbDrone.Host/Bootstrap.cs b/src/NzbDrone.Host/Bootstrap.cs
index 2890d4ec3..1b0d9fa70 100644
--- a/src/NzbDrone.Host/Bootstrap.cs
+++ b/src/NzbDrone.Host/Bootstrap.cs
@@ -51,6 +51,7 @@ namespace NzbDrone.Host
catch (TerminateApplicationException e)
{
Logger.Info(e.Message);
+ LogManager.Configuration = null;
}
}
diff --git a/src/NzbDrone.Host/MainAppContainerBuilder.cs b/src/NzbDrone.Host/MainAppContainerBuilder.cs
index ce7d53216..ea4ace057 100644
--- a/src/NzbDrone.Host/MainAppContainerBuilder.cs
+++ b/src/NzbDrone.Host/MainAppContainerBuilder.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using Nancy.Bootstrapper;
using NzbDrone.Api;
using NzbDrone.Common.Composition;
diff --git a/src/NzbDrone.Host/NzbDrone.Host.csproj b/src/NzbDrone.Host/NzbDrone.Host.csproj
index 7a0f05c83..8ad545c0d 100644
--- a/src/NzbDrone.Host/NzbDrone.Host.csproj
+++ b/src/NzbDrone.Host/NzbDrone.Host.csproj
@@ -117,7 +117,7 @@
-
+
@@ -195,9 +195,7 @@
NzbDrone.SignalR
-
-
-
+
diff --git a/src/NzbDrone.Host/NzbDroneProcessService.cs b/src/NzbDrone.Host/SingleInstancePolicy.cs
similarity index 72%
rename from src/NzbDrone.Host/NzbDroneProcessService.cs
rename to src/NzbDrone.Host/SingleInstancePolicy.cs
index c13a46f5b..d88b11117 100644
--- a/src/NzbDrone.Host/NzbDroneProcessService.cs
+++ b/src/NzbDrone.Host/SingleInstancePolicy.cs
@@ -16,12 +16,17 @@ namespace NzbDrone.Host
{
private readonly IProcessProvider _processProvider;
private readonly IBrowserService _browserService;
+ private readonly INzbDroneProcessProvider _nzbDroneProcessProvider;
private readonly Logger _logger;
- public SingleInstancePolicy(IProcessProvider processProvider, IBrowserService browserService, Logger logger)
+ public SingleInstancePolicy(IProcessProvider processProvider,
+ IBrowserService browserService,
+ INzbDroneProcessProvider nzbDroneProcessProvider,
+ Logger logger)
{
_processProvider = processProvider;
_browserService = browserService;
+ _nzbDroneProcessProvider = nzbDroneProcessProvider;
_logger = logger;
}
@@ -51,11 +56,10 @@ namespace NzbDrone.Host
private List GetOtherNzbDroneProcessIds()
{
var currentId = _processProvider.GetCurrentProcess().Id;
- var consoleIds = _processProvider.FindProcessByName(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME)
- .Select(c => c.Id);
- var winformIds = _processProvider.FindProcessByName(ProcessProvider.NZB_DRONE_PROCESS_NAME).Select(c => c.Id);
-
- var otherProcesses = consoleIds.Union(winformIds).Except(new[] { currentId }).ToList();
+ var otherProcesses = _nzbDroneProcessProvider.GetNzbDroneProcesses()
+ .Select(c => c.Id)
+ .Except(new[] {currentId})
+ .ToList();
if (otherProcesses.Any())
{
diff --git a/src/NzbDrone.Mono/NzbDrone.Mono.csproj b/src/NzbDrone.Mono/NzbDrone.Mono.csproj
index 91d0efeb3..e342f9a16 100644
--- a/src/NzbDrone.Mono/NzbDrone.Mono.csproj
+++ b/src/NzbDrone.Mono/NzbDrone.Mono.csproj
@@ -70,6 +70,7 @@
+
diff --git a/src/NzbDrone.Mono/NzbDroneProcessProvider.cs b/src/NzbDrone.Mono/NzbDroneProcessProvider.cs
new file mode 100644
index 000000000..3b2ff34d7
--- /dev/null
+++ b/src/NzbDrone.Mono/NzbDroneProcessProvider.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using NzbDrone.Common.Model;
+using NzbDrone.Common.Processes;
+
+namespace NzbDrone.Mono
+{
+ public class NzbDroneProcessProvider : INzbDroneProcessProvider
+ {
+ private readonly IProcessProvider _processProvider;
+
+ public NzbDroneProcessProvider(IProcessProvider processProvider)
+ {
+ _processProvider = processProvider;
+ }
+
+ public List GetNzbDroneProcesses()
+ {
+ var monoProcesses = _processProvider.FindProcessByName("mono");
+
+ return monoProcesses.Where(c =>
+ {
+ var processArgs = _processProvider.StartAndCapture("ps", String.Format("--pid {0} -o args=", c.Id));
+
+ return processArgs.Standard.Any(p => p.Contains(ProcessProvider.NZB_DRONE_PROCESS_NAME) ||
+ p.Contains(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME));
+ }).ToList();
+ }
+ }
+}
diff --git a/src/NzbDrone.Windows/NzbDrone.Windows.csproj b/src/NzbDrone.Windows/NzbDrone.Windows.csproj
index 607f09a4e..77e47f03c 100644
--- a/src/NzbDrone.Windows/NzbDrone.Windows.csproj
+++ b/src/NzbDrone.Windows/NzbDrone.Windows.csproj
@@ -63,6 +63,7 @@
+
diff --git a/src/NzbDrone.Windows/NzbDroneProcessProvider.cs b/src/NzbDrone.Windows/NzbDroneProcessProvider.cs
new file mode 100644
index 000000000..c75f4cf30
--- /dev/null
+++ b/src/NzbDrone.Windows/NzbDroneProcessProvider.cs
@@ -0,0 +1,25 @@
+using System.Collections.Generic;
+using System.Linq;
+using NzbDrone.Common.Model;
+using NzbDrone.Common.Processes;
+
+namespace NzbDrone.Windows
+{
+ public class NzbDroneProcessProvider : INzbDroneProcessProvider
+ {
+ private readonly IProcessProvider _processProvider;
+
+ public NzbDroneProcessProvider(IProcessProvider processProvider)
+ {
+ _processProvider = processProvider;
+ }
+
+ public List GetNzbDroneProcesses()
+ {
+ var consoleProcesses = _processProvider.FindProcessByName(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME);
+ var winformProcesses = _processProvider.FindProcessByName(ProcessProvider.NZB_DRONE_PROCESS_NAME);
+
+ return consoleProcesses.Concat(winformProcesses).ToList();
+ }
+ }
+}
diff --git a/src/UI/System/SystemLayoutTemplate.html b/src/UI/System/SystemLayoutTemplate.html
index 3e5a10b8e..1ee3a2349 100644
--- a/src/UI/System/SystemLayoutTemplate.html
+++ b/src/UI/System/SystemLayoutTemplate.html
@@ -7,11 +7,9 @@
- {{#if_windows}}
- {{/if_windows}}