diff --git a/src/Microsoft.AspNet.SignalR.Core/Messaging/MessageBroker.cs b/src/Microsoft.AspNet.SignalR.Core/Messaging/MessageBroker.cs index 76c24161d..8995f96bc 100644 --- a/src/Microsoft.AspNet.SignalR.Core/Messaging/MessageBroker.cs +++ b/src/Microsoft.AspNet.SignalR.Core/Messaging/MessageBroker.cs @@ -295,6 +295,14 @@ namespace Microsoft.AspNet.SignalR.Messaging 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 8fc4151d9..3387ba421 100644 --- a/src/NzbDrone.Api/Config/HostConfigResource.cs +++ b/src/NzbDrone.Api/Config/HostConfigResource.cs @@ -14,6 +14,7 @@ namespace NzbDrone.Api.Config 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 8cef57af6..679fe2f1c 100644 --- a/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs +++ b/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs @@ -16,6 +16,7 @@ namespace NzbDrone.Common.EnvironmentInfo bool IsWindowsService { get; } bool IsConsole { get; } bool IsRunning { get; set; } + bool RestartPending { get; set; } string ExecutingApplication { get; } } @@ -83,6 +84,7 @@ namespace NzbDrone.Common.EnvironmentInfo } 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 3331b39e4..dbf4e6d65 100644 --- a/src/NzbDrone.Common/EnvironmentInfo/StartupContext.cs +++ b/src/NzbDrone.Common/EnvironmentInfo/StartupContext.cs @@ -18,6 +18,7 @@ namespace NzbDrone.Common.EnvironmentInfo 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 f82da6eb1..9e8f5dd1b 100644 --- a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs +++ b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs @@ -28,6 +28,7 @@ namespace NzbDrone.Core.Configuration 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 @@ namespace NzbDrone.Core.Configuration 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 8b2f3a21e..1d02490c6 100644 --- a/src/NzbDrone.Core/Lifecycle/LifecycleService.cs +++ b/src/NzbDrone.Core/Lifecycle/LifecycleService.cs @@ -48,22 +48,12 @@ namespace NzbDrone.Core.Lifecycle { _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 1e6a5f713..c299c4870 100644 --- a/src/NzbDrone.Host/ApplicationServer.cs +++ b/src/NzbDrone.Host/ApplicationServer.cs @@ -55,7 +55,7 @@ namespace NzbDrone.Host { 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 @@ namespace NzbDrone.Host 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 cac59c291..ca277851c 100644 --- a/src/NzbDrone.Host/Bootstrap.cs +++ b/src/NzbDrone.Host/Bootstrap.cs @@ -5,6 +5,7 @@ using NLog; 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 @@ namespace NzbDrone.Host { if (!IsInUtilityMode(applicationModes)) { + if (startupContext.Flags.Contains(StartupContext.RESTART)) + { + Thread.Sleep(2000); + } + EnsureSingleInstance(applicationModes == ApplicationModes.Service, startupContext); } @@ -73,12 +79,7 @@ namespace NzbDrone.Host 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 703828a2f..861ae81e9 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 000000000..8b07dfbc2 --- /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 44d9e3d11..126283e4f 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 2732cdfdc..000000000 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 2732cdfdc..000000000 Binary files a/src/UpgradeLog2.htm and /dev/null differ