diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-10-07 10:38:31 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-10-07 10:38:31 -0400 |
| commit | 65f78ea5ad19620d73eba54ac289fb78ef70af2b (patch) | |
| tree | 204602c95134b6e81c8cd6efc83c7b67374eeab3 /MediaBrowser.ServerApplication | |
| parent | 3f1cafdc814c6d0ef866f1c68dcb4dd1034099ec (diff) | |
added CanSelfRestart
Diffstat (limited to 'MediaBrowser.ServerApplication')
| -rw-r--r-- | MediaBrowser.ServerApplication/ApplicationHost.cs | 19 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/MainStartup.cs | 21 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/Native/NativeApp.cs | 12 |
3 files changed, 47 insertions, 5 deletions
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 985a27d93..b74fd8a73 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -181,6 +181,15 @@ namespace MediaBrowser.ServerApplication } /// <summary> + /// Gets a value indicating whether this instance can self restart. + /// </summary> + /// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value> + public override bool CanSelfRestart + { + get { return NativeApp.CanSelfRestart; } + } + + /// <summary> /// Runs the startup tasks. /// </summary> /// <returns>Task.</returns> @@ -384,7 +393,7 @@ namespace MediaBrowser.ServerApplication await repo.Initialize().ConfigureAwait(false); - ((UserDataManager) UserDataManager).Repository = repo; + ((UserDataManager)UserDataManager).Repository = repo; } /// <summary> @@ -493,6 +502,11 @@ namespace MediaBrowser.ServerApplication /// </summary> 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 e69d46661..b4b2cf107 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)) @@ -163,16 +164,30 @@ namespace MediaBrowser.ServerApplication } /// <summary> + /// Gets a value indicating whether this instance can self restart. + /// </summary> + /// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value> + public static bool CanSelfRestart + { + get + { + return true; + } + } + + /// <summary> /// Begins the log. /// </summary> /// <param name="logger">The logger.</param> - private static void BeginLog(ILogger logger) + /// <param name="appPaths">The app paths.</param> + 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); } /// <summary> diff --git a/MediaBrowser.ServerApplication/Native/NativeApp.cs b/MediaBrowser.ServerApplication/Native/NativeApp.cs index ea4218afc..0e114b166 100644 --- a/MediaBrowser.ServerApplication/Native/NativeApp.cs +++ b/MediaBrowser.ServerApplication/Native/NativeApp.cs @@ -21,5 +21,17 @@ namespace MediaBrowser.ServerApplication.Native { MainStartup.Restart(); } + + /// <summary> + /// Determines whether this instance [can self restart]. + /// </summary> + /// <returns><c>true</c> if this instance [can self restart]; otherwise, <c>false</c>.</returns> + public static bool CanSelfRestart + { + get + { + return MainStartup.CanSelfRestart; + } + } } } |
