fixes #224 - Exception trying to start server after a reboot

This commit is contained in:
Luke Pulverenti 2013-05-07 14:49:42 -04:00
parent b4bcb07c38
commit de6acec504

View File

@ -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>()),
@ -405,6 +406,31 @@ 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>
/// Restarts this instance.
/// </summary>