diff options
| author | Eric Reed <ebr@mediabrowser3.com> | 2013-05-07 15:27:23 -0400 |
|---|---|---|
| committer | Eric Reed <ebr@mediabrowser3.com> | 2013-05-07 15:27:23 -0400 |
| commit | 52a726786477fc94f137fc5ac93b8bed99a78110 (patch) | |
| tree | b72826476f41aa58f4e254431a9b2c64eded2115 /MediaBrowser.ServerApplication | |
| parent | 67f2b1b2bacee5ef3272076e84b1bf305f9b69c7 (diff) | |
| parent | 0934a9ca766ae6794e7e8aa506ebf48c63a25526 (diff) | |
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Diffstat (limited to 'MediaBrowser.ServerApplication')
| -rw-r--r-- | MediaBrowser.ServerApplication/ApplicationHost.cs | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 07e615b1d..37e6d1b8d 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -382,7 +382,8 @@ namespace MediaBrowser.ServerApplication HttpServer.Init(GetExports<IRestfulService>(false)); ServerManager.AddWebSocketListeners(GetExports<IWebSocketListener>(false)); - ServerManager.Start(); + + StartServer(true); }, () => LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(), GetExports<IVirtualFolderCreator>(), GetExports<IItemResolver>(), GetExports<IIntroProvider>(), GetExports<IBaseItemComparer>()), @@ -406,6 +407,52 @@ namespace MediaBrowser.ServerApplication } /// <summary> + /// Starts the server. + /// </summary> + /// <param name="retryOnFailure">if set to <c>true</c> [retry on failure].</param> + private void StartServer(bool retryOnFailure) + { + try + { + ServerManager.Start(); + } + catch + { + if (retryOnFailure) + { + RegisterServerWithAdministratorAccess(); + + StartServer(false); + } + else + { + throw; + } + } + } + + /// <summary> + /// Called when [configuration updated]. + /// </summary> + /// <param name="sender">The sender.</param> + /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> + protected override void OnConfigurationUpdated(object sender, EventArgs e) + { + base.OnConfigurationUpdated(sender, e); + + if (!string.Equals(HttpServer.UrlPrefix, ServerKernel.HttpServerUrlPrefix, StringComparison.OrdinalIgnoreCase)) + { + NotifyPendingRestart(); + } + + else if (!ServerManager.SupportsNativeWebSocket && ServerManager.WebSocketPortNumber != ServerConfigurationManager.Configuration.LegacyWebSocketPortNumber) + { + NotifyPendingRestart(); + } + + } + + /// <summary> /// Restarts this instance. /// </summary> public override void Restart() |
