From de6acec5047e54e284025a3e9749ab9afa257d45 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 7 May 2013 14:49:42 -0400 Subject: [PATCH] fixes #224 - Exception trying to start server after a reboot --- .../ApplicationHost.cs | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) 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. ///