diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs index e7a9c00c61..daa664a388 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -590,6 +590,12 @@ namespace MediaBrowser.Common.Implementations Plugins = list; } + /// + /// Gets a value indicating whether this instance can self restart. + /// + /// true if this instance can self restart; otherwise, false. + public abstract bool CanSelfRestart { get; } + /// /// Notifies that the kernel that a change has been made that requires a restart /// diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs index 177df5afaa..56b86a3c11 100644 --- a/MediaBrowser.Common/IApplicationHost.cs +++ b/MediaBrowser.Common/IApplicationHost.cs @@ -24,6 +24,12 @@ namespace MediaBrowser.Common /// true if this instance has pending kernel reload; otherwise, false. bool HasPendingRestart { get; } + /// + /// Gets a value indicating whether this instance can self restart. + /// + /// true if this instance can self restart; otherwise, false. + bool CanSelfRestart { get; } + /// /// Occurs when [has pending restart changed]. /// diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs index 60d0564d83..d736298b8f 100644 --- a/MediaBrowser.Model/System/SystemInfo.cs +++ b/MediaBrowser.Model/System/SystemInfo.cs @@ -62,6 +62,12 @@ namespace MediaBrowser.Model.System /// true if [supports native web socket]; otherwise, false. public bool SupportsNativeWebSocket { get; set; } + /// + /// Gets or sets a value indicating whether this instance can self restart. + /// + /// true if this instance can self restart; otherwise, false. + public bool CanSelfRestart { get; set; } + /// /// Gets or sets plugin assemblies that failed to load. /// diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 985a27d93c..b74fd8a739 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -180,6 +180,15 @@ namespace MediaBrowser.ServerApplication } + /// + /// Gets a value indicating whether this instance can self restart. + /// + /// true if this instance can self restart; otherwise, false. + public override bool CanSelfRestart + { + get { return NativeApp.CanSelfRestart; } + } + /// /// Runs the startup tasks. /// @@ -384,7 +393,7 @@ namespace MediaBrowser.ServerApplication await repo.Initialize().ConfigureAwait(false); - ((UserDataManager) UserDataManager).Repository = repo; + ((UserDataManager)UserDataManager).Repository = repo; } /// @@ -493,6 +502,11 @@ namespace MediaBrowser.ServerApplication /// public override async Task Restart() { + if (!CanSelfRestart) + { + throw new InvalidOperationException("The server is unable to self-restart. Please restart manually."); + } + try { await SessionManager.SendServerRestartNotification(CancellationToken.None).ConfigureAwait(false); @@ -588,7 +602,8 @@ namespace MediaBrowser.ServerApplication ProgramDataPath = ApplicationPaths.ProgramDataPath, MacAddress = GetMacAddress(), HttpServerPortNumber = ServerConfigurationManager.Configuration.HttpServerPortNumber, - OperatingSystem = Environment.OSVersion.ToString() + OperatingSystem = Environment.OSVersion.ToString(), + CanSelfRestart = CanSelfRestart }; } diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index e69d466613..b4b2cf1071 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Constants; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Constants; using MediaBrowser.Common.Implementations.Logging; using MediaBrowser.Common.Implementations.Updates; using MediaBrowser.Controller.IO; @@ -44,7 +45,7 @@ namespace MediaBrowser.ServerApplication var logger = _logger = logManager.GetLogger("Main"); - BeginLog(logger); + BeginLog(logger, appPaths); // Install directly if (string.Equals(startFlag, "-installservice", StringComparison.OrdinalIgnoreCase)) @@ -162,17 +163,31 @@ namespace MediaBrowser.ServerApplication return new ServerApplicationPaths(); } + /// + /// Gets a value indicating whether this instance can self restart. + /// + /// true if this instance can self restart; otherwise, false. + public static bool CanSelfRestart + { + get + { + return true; + } + } + /// /// Begins the log. /// /// The logger. - private static void BeginLog(ILogger logger) + /// The app paths. + private static void BeginLog(ILogger logger, IApplicationPaths appPaths) { logger.Info("Media Browser Server started"); logger.Info("Command line: {0}", string.Join(" ", Environment.GetCommandLineArgs())); logger.Info("Server: {0}", Environment.MachineName); logger.Info("Operating system: {0}", Environment.OSVersion.ToString()); + logger.Info("Program data path: {0}", appPaths.ProgramDataPath); } /// diff --git a/MediaBrowser.ServerApplication/Native/NativeApp.cs b/MediaBrowser.ServerApplication/Native/NativeApp.cs index ea4218afc9..0e114b166d 100644 --- a/MediaBrowser.ServerApplication/Native/NativeApp.cs +++ b/MediaBrowser.ServerApplication/Native/NativeApp.cs @@ -21,5 +21,17 @@ namespace MediaBrowser.ServerApplication.Native { MainStartup.Restart(); } + + /// + /// Determines whether this instance [can self restart]. + /// + /// true if this instance [can self restart]; otherwise, false. + public static bool CanSelfRestart + { + get + { + return MainStartup.CanSelfRestart; + } + } } } diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index b7fd2a38f0..ff1ee204c2 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.222 + 3.0.223 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index f6b3aeef85..2a650c467e 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.222 + 3.0.223 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index b8227fa043..2d30823a30 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.222 + 3.0.223 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +