The Free Software Media System - Server Backend & API
Fix startup message
Claus Vium2f79c3095bb7
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.csindex c8af6b73a5..8e9a581eae 100644--- a/Emby.Server.Implementations/ApplicationHost.cs+++ b/Emby.Server.Implementations/ApplicationHost.cs@@ -132,6 +132,8 @@ namespace Emby.Server.Implementations/// </summary>public bool CanSelfRestart => _startupOptions.RestartPath != null;+ public bool CoreStartupHasCompleted { get; private set; }+public virtual bool CanLaunchWebBrowser{get@@ -446,7 +448,7 @@ namespace Emby.Server.ImplementationsLogger.LogInformation("Executed all pre-startup entry points in {Elapsed:g}", stopWatch.Elapsed);Logger.LogInformation("Core startup complete");-+ CoreStartupHasCompleted = true;stopWatch.Restart();await Task.WhenAll(StartEntryPoints(entryPoints, false)).ConfigureAwait(false);Logger.LogInformation("Executed all post-startup entry points in {Elapsed:g}", stopWatch.Elapsed);diff --git a/Jellyfin.Server/Middleware/ServerStartupMessageMiddleware.cs b/Jellyfin.Server/Middleware/ServerStartupMessageMiddleware.csindex 4f347d6d3b..ea81c03a20 100644--- a/Jellyfin.Server/Middleware/ServerStartupMessageMiddleware.cs+++ b/Jellyfin.Server/Middleware/ServerStartupMessageMiddleware.cs@@ -1,5 +1,6 @@using System.Net.Mime;using System.Threading.Tasks;+using MediaBrowser.Controller;using MediaBrowser.Model.Globalization;using Microsoft.AspNetCore.Http;@@ -25,10 +26,20 @@ namespace Jellyfin.Server.Middleware/// Executes the middleware action./// </summary>/// <param name="httpContext">The current HTTP context.</param>+ /// <param name="serverApplicationHost">The server application host.</param>/// <param name="localizationManager">The localization manager.</param>/// <returns>The async task.</returns>- public async Task Invoke(HttpContext httpContext, ILocalizationManager localizationManager)+ public async Task Invoke(+ HttpContext httpContext,+ IServerApplicationHost serverApplicationHost,+ ILocalizationManager localizationManager){+ if (serverApplicationHost.CoreStartupHasCompleted)+ {+ await _next(httpContext).ConfigureAwait(false);+ return;+ }+var message = localizationManager.GetLocalizedString("StartupEmbyServerIsLoading");httpContext.Response.StatusCode = StatusCodes.Status503ServiceUnavailable;httpContext.Response.ContentType = MediaTypeNames.Text.Html;diff --git a/Jellyfin.Server/Startup.cs b/Jellyfin.Server/Startup.csindex 80f6794206..c197888da6 100644--- a/Jellyfin.Server/Startup.cs+++ b/Jellyfin.Server/Startup.cs@@ -123,6 +123,7 @@ namespace Jellyfin.Serverapp.UseCorsOptionsResponse();app.UseBaseUrlRedirection();app.UseWebSocketHandler();+ app.UseServerStartupMessage();app.UseEndpoints(endpoints =>{@@ -133,8 +134,6 @@ namespace Jellyfin.Server}});- app.UseServerStartupMessage();-// Add type descriptor for legacy datetime parsing.TypeDescriptor.AddAttributes(typeof(DateTime?), new TypeConverterAttribute(typeof(DateTimeTypeConverter)));}diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.csindex d482c19d98..9f4c00e1c8 100644--- a/MediaBrowser.Controller/IServerApplicationHost.cs+++ b/MediaBrowser.Controller/IServerApplicationHost.cs@@ -20,6 +20,8 @@ namespace MediaBrowser.ControllerIServiceProvider ServiceProvider { get; }+ bool CoreStartupHasCompleted { get; }+bool CanLaunchWebBrowser { get; }/// <summary>