mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 13:57:14 -04:00
improved messages with startup failures
This commit is contained in:
parent
a2fb45ba8e
commit
755d98edc0
@ -5,6 +5,9 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MediaBrowser.Common.Net
|
namespace MediaBrowser.Common.Net
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interface IServerManager
|
||||||
|
/// </summary>
|
||||||
public interface IServerManager : IDisposable
|
public interface IServerManager : IDisposable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -22,7 +25,14 @@ namespace MediaBrowser.Common.Net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts this instance.
|
/// Starts this instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Start();
|
/// <param name="urlPrefix">The URL prefix.</param>
|
||||||
|
/// <param name="enableHttpLogging">if set to <c>true</c> [enable HTTP logging].</param>
|
||||||
|
void Start(string urlPrefix, bool enableHttpLogging);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Starts the web socket server.
|
||||||
|
/// </summary>
|
||||||
|
void StartWebSocketServer();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a message to all clients currently connected via a web socket
|
/// Sends a message to all clients currently connected via a web socket
|
||||||
|
@ -529,7 +529,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
{
|
{
|
||||||
new ClientWebSocket();
|
new ClientWebSocket();
|
||||||
|
|
||||||
_supportsNativeWebSocket = true;
|
_supportsNativeWebSocket = false;
|
||||||
}
|
}
|
||||||
catch (PlatformNotSupportedException)
|
catch (PlatformNotSupportedException)
|
||||||
{
|
{
|
||||||
|
@ -118,43 +118,44 @@ namespace MediaBrowser.Server.Implementations.ServerManager
|
|||||||
_jsonSerializer = jsonSerializer;
|
_jsonSerializer = jsonSerializer;
|
||||||
_applicationHost = applicationHost;
|
_applicationHost = applicationHost;
|
||||||
ConfigurationManager = configurationManager;
|
ConfigurationManager = configurationManager;
|
||||||
|
|
||||||
ConfigurationManager.ConfigurationUpdated += ConfigurationUpdated;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts this instance.
|
/// Starts this instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Start()
|
public void Start(string urlPrefix, bool enableHttpLogging)
|
||||||
{
|
{
|
||||||
ReloadHttpServer();
|
ReloadHttpServer(urlPrefix, enableHttpLogging);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StartWebSocketServer()
|
||||||
|
{
|
||||||
if (!SupportsNativeWebSocket)
|
if (!SupportsNativeWebSocket)
|
||||||
{
|
{
|
||||||
ReloadExternalWebSocketServer();
|
ReloadExternalWebSocketServer(ConfigurationManager.Configuration.LegacyWebSocketPortNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts the external web socket server.
|
/// Starts the external web socket server.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void ReloadExternalWebSocketServer()
|
private void ReloadExternalWebSocketServer(int portNumber)
|
||||||
{
|
{
|
||||||
DisposeExternalWebSocketServer();
|
DisposeExternalWebSocketServer();
|
||||||
|
|
||||||
ExternalWebSocketServer = _applicationHost.Resolve<IWebSocketServer>();
|
ExternalWebSocketServer = _applicationHost.Resolve<IWebSocketServer>();
|
||||||
|
|
||||||
ExternalWebSocketServer.Start(ConfigurationManager.Configuration.LegacyWebSocketPortNumber);
|
ExternalWebSocketServer.Start(portNumber);
|
||||||
ExternalWebSocketServer.WebSocketConnected += HttpServer_WebSocketConnected;
|
ExternalWebSocketServer.WebSocketConnected += HttpServer_WebSocketConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Restarts the Http Server, or starts it if not currently running
|
/// Restarts the Http Server, or starts it if not currently running
|
||||||
/// </summary>
|
/// </summary>
|
||||||
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
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
@ -166,8 +167,8 @@ namespace MediaBrowser.Server.Implementations.ServerManager
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
HttpServer = _applicationHost.Resolve<IHttpServer>();
|
HttpServer = _applicationHost.Resolve<IHttpServer>();
|
||||||
HttpServer.EnableHttpRequestLogging = ConfigurationManager.Configuration.EnableHttpLevelLogging;
|
HttpServer.EnableHttpRequestLogging = enableHttpLogging;
|
||||||
HttpServer.Start(_applicationHost.HttpServerUrlPrefix);
|
HttpServer.Start(urlPrefix);
|
||||||
}
|
}
|
||||||
catch (SocketException ex)
|
catch (SocketException ex)
|
||||||
{
|
{
|
||||||
@ -375,17 +376,6 @@ namespace MediaBrowser.Server.Implementations.ServerManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Handles the ConfigurationUpdated event of the _kernel control.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender">The source of the event.</param>
|
|
||||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
|
||||||
/// <exception cref="System.NotImplementedException"></exception>
|
|
||||||
void ConfigurationUpdated(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
HttpServer.EnableHttpRequestLogging = ConfigurationManager.Configuration.EnableHttpLevelLogging;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds the web socket listeners.
|
/// Adds the web socket listeners.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -54,6 +54,8 @@ namespace MediaBrowser.Server.Implementations.WebSocket
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="portNumber">The port number.</param>
|
/// <param name="portNumber">The port number.</param>
|
||||||
public void Start(int portNumber)
|
public void Start(int portNumber)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
WebSocketServer = new WebSocketServer(portNumber, IPAddress.Any)
|
WebSocketServer = new WebSocketServer(portNumber, IPAddress.Any)
|
||||||
{
|
{
|
||||||
@ -61,8 +63,6 @@ namespace MediaBrowser.Server.Implementations.WebSocket
|
|||||||
TimeOut = TimeSpan.FromHours(12)
|
TimeOut = TimeSpan.FromHours(12)
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
WebSocketServer.Start();
|
WebSocketServer.Start();
|
||||||
}
|
}
|
||||||
catch (SocketException ex)
|
catch (SocketException ex)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using MediaBrowser.Api;
|
using System.Windows.Forms;
|
||||||
|
using MediaBrowser.Api;
|
||||||
using MediaBrowser.Common;
|
using MediaBrowser.Common;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Constants;
|
using MediaBrowser.Common.Constants;
|
||||||
@ -475,7 +476,7 @@ namespace MediaBrowser.ServerApplication
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ServerManager.Start();
|
ServerManager.Start(HttpServerUrlPrefix, ServerConfigurationManager.Configuration.EnableHttpLevelLogging);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -490,6 +491,8 @@ namespace MediaBrowser.ServerApplication
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ServerManager.StartWebSocketServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -501,6 +504,8 @@ namespace MediaBrowser.ServerApplication
|
|||||||
{
|
{
|
||||||
base.OnConfigurationUpdated(sender, e);
|
base.OnConfigurationUpdated(sender, e);
|
||||||
|
|
||||||
|
HttpServer.EnableHttpRequestLogging = ServerConfigurationManager.Configuration.EnableHttpLevelLogging;
|
||||||
|
|
||||||
if (!string.Equals(HttpServer.UrlPrefix, HttpServerUrlPrefix, StringComparison.OrdinalIgnoreCase))
|
if (!string.Equals(HttpServer.UrlPrefix, HttpServerUrlPrefix, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
NotifyPendingRestart();
|
NotifyPendingRestart();
|
||||||
|
Loading…
Reference in New Issue
Block a user