Fix startup message

This commit is contained in:
Claus Vium 2020-09-03 11:54:38 +02:00
parent 571d0570f5
commit 2f79c3095b
4 changed files with 18 additions and 4 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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)));
}

View file

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