From 65f78ea5ad19620d73eba54ac289fb78ef70af2b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 7 Oct 2013 10:38:31 -0400 Subject: added CanSelfRestart --- MediaBrowser.ServerApplication/ApplicationHost.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'MediaBrowser.ServerApplication/ApplicationHost.cs') 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 }; } -- cgit v1.2.3