diff --git a/src/Microsoft.AspNet.SignalR.Core/Messaging/MessageBroker.cs b/src/Microsoft.AspNet.SignalR.Core/Messaging/MessageBroker.cs index 76c24161dd..8995f96bca 100644 --- a/src/Microsoft.AspNet.SignalR.Core/Messaging/MessageBroker.cs +++ b/src/Microsoft.AspNet.SignalR.Core/Messaging/MessageBroker.cs @@ -295,6 +295,14 @@ protected virtual void Dispose(bool disposing) Trace.TraceEvent(TraceEventType.Verbose, 0, "Dispoing the broker"); + //Check if OS is not Windows and exit + var platform = (int)Environment.OSVersion.Platform; + + if ((platform == 4) || (platform == 6) || (platform == 128)) + { + return; + } + // Wait for all threads to stop working WaitForDrain(); diff --git a/src/NzbDrone.Api/Config/HostConfigResource.cs b/src/NzbDrone.Api/Config/HostConfigResource.cs index 8fc4151d94..3387ba4219 100644 --- a/src/NzbDrone.Api/Config/HostConfigResource.cs +++ b/src/NzbDrone.Api/Config/HostConfigResource.cs @@ -14,6 +14,7 @@ public class HostConfigResource : RestResource public String Password { get; set; } public String LogLevel { get; set; } public String Branch { get; set; } + public Boolean AutoUpdate { get; set; } public String ApiKey { get; set; } public Boolean Torrent { get; set; } public String SslCertHash { get; set; } diff --git a/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs b/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs index 8cef57af69..679fe2f1c3 100644 --- a/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs +++ b/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs @@ -16,6 +16,7 @@ public interface IRuntimeInfo bool IsWindowsService { get; } bool IsConsole { get; } bool IsRunning { get; set; } + bool RestartPending { get; set; } string ExecutingApplication { get; } } @@ -83,6 +84,7 @@ public bool IsConsole } public bool IsRunning { get; set; } + public bool RestartPending { get; set; } public string ExecutingApplication { get; private set; } public static bool IsProduction { get; private set; } diff --git a/src/NzbDrone.Common/EnvironmentInfo/StartupContext.cs b/src/NzbDrone.Common/EnvironmentInfo/StartupContext.cs index 3331b39e46..dbf4e6d657 100644 --- a/src/NzbDrone.Common/EnvironmentInfo/StartupContext.cs +++ b/src/NzbDrone.Common/EnvironmentInfo/StartupContext.cs @@ -18,6 +18,7 @@ public class StartupContext : IStartupContext internal const string UNINSTALL_SERVICE = "u"; public const string HELP = "?"; public const string TERMINATE = "terminateexisting"; + public const string RESTART = "restart"; public StartupContext(params string[] args) { diff --git a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs index f82da6eb1d..9e8f5dd1bf 100644 --- a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs +++ b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs @@ -28,6 +28,7 @@ public interface IConfigFileProvider : IHandleAsync string Password { get; } string LogLevel { get; } string Branch { get; } + bool AutoUpdate { get; } string ApiKey { get; } bool Torrent { get; } string SslCertHash { get; } @@ -133,6 +134,11 @@ public string Branch get { return GetValue("Branch", "master").ToLowerInvariant(); } } + public bool AutoUpdate + { + get { return GetValueBoolean("AutoUpdate", false, persist: false); } + } + public string Username { get { return GetValue("Username", ""); } diff --git a/src/NzbDrone.Core/Lifecycle/LifecycleService.cs b/src/NzbDrone.Core/Lifecycle/LifecycleService.cs index 8b2f3a21e8..1d02490c69 100644 --- a/src/NzbDrone.Core/Lifecycle/LifecycleService.cs +++ b/src/NzbDrone.Core/Lifecycle/LifecycleService.cs @@ -48,22 +48,12 @@ public void Execute(RestartCommand message) { _logger.Info("Restart requested."); - if (OsInfo.IsMono) - { - _processProvider.SpawnNewProcess(_runtimeInfo.ExecutingApplication, "--terminateexisting --nobrowser"); - } - _eventAggregator.PublishEvent(new ApplicationShutdownRequested(true)); if (_runtimeInfo.IsWindowsService) { _serviceProvider.Restart(ServiceProvider.NZBDRONE_SERVICE_NAME); } - - else - { - _processProvider.SpawnNewProcess(_runtimeInfo.ExecutingApplication, "--terminateexisting --nobrowser"); - } } } } diff --git a/src/NzbDrone.Host/ApplicationServer.cs b/src/NzbDrone.Host/ApplicationServer.cs index 1e6a5f7133..c299c48708 100644 --- a/src/NzbDrone.Host/ApplicationServer.cs +++ b/src/NzbDrone.Host/ApplicationServer.cs @@ -55,7 +55,7 @@ public void Start() { if (OsInfo.IsMono) { - Console.CancelKeyPress += (sender, eventArgs) => _processProvider.Kill(_processProvider.GetCurrentProcess().Id); + Console.CancelKeyPress += (sender, eventArgs) => LogManager.Configuration = null; } _runtimeInfo.IsRunning = true; @@ -90,13 +90,14 @@ private void Shutdown() public void Handle(ApplicationShutdownRequested message) { - if (OsInfo.IsMono) + if (!_runtimeInfo.IsWindowsService) { - _processProvider.Kill(_processProvider.GetCurrentProcess().Id); - } + if (message.Restarting) + { + _runtimeInfo.RestartPending = true; + } - if (!_runtimeInfo.IsWindowsService && !message.Restarting) - { + LogManager.Configuration = null; Shutdown(); } } diff --git a/src/NzbDrone.Host/Bootstrap.cs b/src/NzbDrone.Host/Bootstrap.cs index cac59c2913..ca277851c0 100644 --- a/src/NzbDrone.Host/Bootstrap.cs +++ b/src/NzbDrone.Host/Bootstrap.cs @@ -5,6 +5,7 @@ using NzbDrone.Common.Composition; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Instrumentation; +using NzbDrone.Common.Processes; using NzbDrone.Common.Security; using NzbDrone.Core.Datastore; @@ -59,6 +60,11 @@ private static void Start(ApplicationModes applicationModes, StartupContext star { if (!IsInUtilityMode(applicationModes)) { + if (startupContext.Flags.Contains(StartupContext.RESTART)) + { + Thread.Sleep(2000); + } + EnsureSingleInstance(applicationModes == ApplicationModes.Service, startupContext); } @@ -73,12 +79,7 @@ private static void SpinToExit(ApplicationModes applicationModes) return; } - var runTimeInfo = _container.Resolve(); - - while (runTimeInfo.IsRunning) - { - Thread.Sleep(1000); - } + _container.Resolve().Spin(); } private static void EnsureSingleInstance(bool isService, StartupContext startupContext) diff --git a/src/NzbDrone.Host/NzbDrone.Host.csproj b/src/NzbDrone.Host/NzbDrone.Host.csproj index 703828a2fd..861ae81e97 100644 --- a/src/NzbDrone.Host/NzbDrone.Host.csproj +++ b/src/NzbDrone.Host/NzbDrone.Host.csproj @@ -101,6 +101,7 @@ + diff --git a/src/NzbDrone.Host/SpinService.cs b/src/NzbDrone.Host/SpinService.cs new file mode 100644 index 0000000000..8b07dfbc28 --- /dev/null +++ b/src/NzbDrone.Host/SpinService.cs @@ -0,0 +1,36 @@ +using System.Threading; +using NzbDrone.Common.EnvironmentInfo; +using NzbDrone.Common.Processes; + +namespace NzbDrone.Host +{ + public interface IWaitForExit + { + void Spin(); + } + + public class SpinService : IWaitForExit + { + private readonly IRuntimeInfo _runtimeInfo; + private readonly IProcessProvider _processProvider; + + public SpinService(IRuntimeInfo runtimeInfo, IProcessProvider processProvider) + { + _runtimeInfo = runtimeInfo; + _processProvider = processProvider; + } + + public void Spin() + { + while (_runtimeInfo.IsRunning) + { + Thread.Sleep(1000); + } + + if (_runtimeInfo.RestartPending) + { + _processProvider.SpawnNewProcess(_runtimeInfo.ExecutingApplication, "--restart --nobrowser"); + } + } + } +} diff --git a/src/UI/Settings/General/GeneralViewTemplate.html b/src/UI/Settings/General/GeneralViewTemplate.html index 44d9e3d114..126283e4f0 100644 --- a/src/UI/Settings/General/GeneralViewTemplate.html +++ b/src/UI/Settings/General/GeneralViewTemplate.html @@ -142,5 +142,28 @@ + + {{#if_mono}} +
+ + +
+
+ {{/if_mono}}
diff --git a/src/UpgradeLog.htm b/src/UpgradeLog.htm deleted file mode 100644 index 2732cdfdc8..0000000000 Binary files a/src/UpgradeLog.htm and /dev/null differ diff --git a/src/UpgradeLog2.htm b/src/UpgradeLog2.htm deleted file mode 100644 index 2732cdfdc8..0000000000 Binary files a/src/UpgradeLog2.htm and /dev/null differ