From 755d98edc0f21f1850652b29854732227c12deef Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 20 Sep 2013 11:37:05 -0400 Subject: improved messages with startup failures --- .../ServerManager/ServerManager.cs | 34 ++++++++-------------- 1 file changed, 12 insertions(+), 22 deletions(-) (limited to 'MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs') diff --git a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs index b63cf0031..a840ae214 100644 --- a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs +++ b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs @@ -118,43 +118,44 @@ namespace MediaBrowser.Server.Implementations.ServerManager _jsonSerializer = jsonSerializer; _applicationHost = applicationHost; ConfigurationManager = configurationManager; - - ConfigurationManager.ConfigurationUpdated += ConfigurationUpdated; } /// /// Starts this instance. /// - public void Start() + public void Start(string urlPrefix, bool enableHttpLogging) { - ReloadHttpServer(); + ReloadHttpServer(urlPrefix, enableHttpLogging); + } + public void StartWebSocketServer() + { if (!SupportsNativeWebSocket) { - ReloadExternalWebSocketServer(); + ReloadExternalWebSocketServer(ConfigurationManager.Configuration.LegacyWebSocketPortNumber); } } /// /// Starts the external web socket server. /// - private void ReloadExternalWebSocketServer() + private void ReloadExternalWebSocketServer(int portNumber) { DisposeExternalWebSocketServer(); ExternalWebSocketServer = _applicationHost.Resolve(); - ExternalWebSocketServer.Start(ConfigurationManager.Configuration.LegacyWebSocketPortNumber); + ExternalWebSocketServer.Start(portNumber); ExternalWebSocketServer.WebSocketConnected += HttpServer_WebSocketConnected; } /// /// Restarts the Http Server, or starts it if not currently running /// - private void ReloadHttpServer() + private void ReloadHttpServer(string urlPrefix, bool enableHttpLogging) { // Only reload if the port has changed, so that we don't disconnect any active users - if (HttpServer != null && HttpServer.UrlPrefix.Equals(_applicationHost.HttpServerUrlPrefix, StringComparison.OrdinalIgnoreCase)) + if (HttpServer != null && HttpServer.UrlPrefix.Equals(urlPrefix, StringComparison.OrdinalIgnoreCase)) { return; } @@ -166,8 +167,8 @@ namespace MediaBrowser.Server.Implementations.ServerManager try { HttpServer = _applicationHost.Resolve(); - HttpServer.EnableHttpRequestLogging = ConfigurationManager.Configuration.EnableHttpLevelLogging; - HttpServer.Start(_applicationHost.HttpServerUrlPrefix); + HttpServer.EnableHttpRequestLogging = enableHttpLogging; + HttpServer.Start(urlPrefix); } catch (SocketException ex) { @@ -375,17 +376,6 @@ namespace MediaBrowser.Server.Implementations.ServerManager } } - /// - /// Handles the ConfigurationUpdated event of the _kernel control. - /// - /// The source of the event. - /// The instance containing the event data. - /// - void ConfigurationUpdated(object sender, EventArgs e) - { - HttpServer.EnableHttpRequestLogging = ConfigurationManager.Configuration.EnableHttpLevelLogging; - } - /// /// Adds the web socket listeners. /// -- cgit v1.2.3