2
0
Claus Vium 4 жил өмнө
parent
commit
2f79c3095b

+ 3 - 1
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.Implementations
             Logger.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);

+ 12 - 1
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;

+ 1 - 2
Jellyfin.Server/Startup.cs

@@ -123,6 +123,7 @@ namespace Jellyfin.Server
             app.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)));
         }

+ 2 - 0
MediaBrowser.Controller/IServerApplicationHost.cs

@@ -20,6 +20,8 @@ namespace MediaBrowser.Controller
 
         IServiceProvider ServiceProvider { get; }
 
+        bool CoreStartupHasCompleted { get; }
+
         bool CanLaunchWebBrowser { get; }
 
         /// <summary>