diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 07e615b1da..309a2c3518 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -382,7 +382,8 @@ namespace MediaBrowser.ServerApplication HttpServer.Init(GetExports(false)); ServerManager.AddWebSocketListeners(GetExports(false)); - ServerManager.Start(); + + StartServer(true); }, () => LibraryManager.AddParts(GetExports(), GetExports(), GetExports(), GetExports(), GetExports()), @@ -405,6 +406,31 @@ namespace MediaBrowser.ServerApplication ); } + /// + /// Starts the server. + /// + /// if set to true [retry on failure]. + private void StartServer(bool retryOnFailure) + { + try + { + ServerManager.Start(); + } + catch + { + if (retryOnFailure) + { + RegisterServerWithAdministratorAccess(); + + StartServer(false); + } + else + { + throw; + } + } + } + /// /// Restarts this instance. ///