mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-18 06:53:07 +03:00
Added Setup overlay app to communicate status of startup
This commit is contained in:
@@ -7,10 +7,13 @@ using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using CommandLine;
|
||||
using Emby.Server.Implementations;
|
||||
using Jellyfin.Networking.Manager;
|
||||
using Jellyfin.Server.Extensions;
|
||||
using Jellyfin.Server.Helpers;
|
||||
using Jellyfin.Server.Implementations;
|
||||
using Jellyfin.Server.ServerSetupApp;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -42,6 +45,9 @@ namespace Jellyfin.Server
|
||||
public const string LoggingConfigFileSystem = "logging.json";
|
||||
|
||||
private static readonly SerilogLoggerFactory _loggerFactory = new SerilogLoggerFactory();
|
||||
private static SetupServer? _setupServer = new();
|
||||
|
||||
private static IHost? _jfHost = null;
|
||||
private static long _startTimestamp;
|
||||
private static ILogger _logger = NullLogger.Instance;
|
||||
private static bool _restartOnShutdown;
|
||||
@@ -68,6 +74,7 @@ namespace Jellyfin.Server
|
||||
{
|
||||
_startTimestamp = Stopwatch.GetTimestamp();
|
||||
ServerApplicationPaths appPaths = StartupHelpers.CreateApplicationPaths(options);
|
||||
await _setupServer!.RunAsync(static () => _jfHost?.Services?.GetService<INetworkManager>(), appPaths).ConfigureAwait(false);
|
||||
|
||||
// $JELLYFIN_LOG_DIR needs to be set for the logger configuration manager
|
||||
Environment.SetEnvironmentVariable("JELLYFIN_LOG_DIR", appPaths.LogDirectoryPath);
|
||||
@@ -122,6 +129,8 @@ namespace Jellyfin.Server
|
||||
if (_restartOnShutdown)
|
||||
{
|
||||
_startTimestamp = Stopwatch.GetTimestamp();
|
||||
_setupServer = new SetupServer();
|
||||
await _setupServer.RunAsync(static () => _jfHost?.Services?.GetService<INetworkManager>(), appPaths).ConfigureAwait(false);
|
||||
}
|
||||
} while (_restartOnShutdown);
|
||||
}
|
||||
@@ -133,11 +142,9 @@ namespace Jellyfin.Server
|
||||
_loggerFactory,
|
||||
options,
|
||||
startupConfig);
|
||||
|
||||
IHost? host = null;
|
||||
try
|
||||
{
|
||||
host = Host.CreateDefaultBuilder()
|
||||
_jfHost = Host.CreateDefaultBuilder()
|
||||
.UseConsoleLifetime()
|
||||
.ConfigureServices(services => appHost.Init(services))
|
||||
.ConfigureWebHostDefaults(webHostBuilder =>
|
||||
@@ -154,14 +161,18 @@ namespace Jellyfin.Server
|
||||
.Build();
|
||||
|
||||
// Re-use the host service provider in the app host since ASP.NET doesn't allow a custom service collection.
|
||||
appHost.ServiceProvider = host.Services;
|
||||
appHost.ServiceProvider = _jfHost.Services;
|
||||
|
||||
await appHost.InitializeServices().ConfigureAwait(false);
|
||||
Migrations.MigrationRunner.Run(appHost, _loggerFactory);
|
||||
|
||||
try
|
||||
{
|
||||
await host.StartAsync().ConfigureAwait(false);
|
||||
await Task.Delay(50000).ConfigureAwait(false);
|
||||
await _setupServer!.StopAsync().ConfigureAwait(false);
|
||||
_setupServer.Dispose();
|
||||
_setupServer = null!;
|
||||
await _jfHost.StartAsync().ConfigureAwait(false);
|
||||
|
||||
if (!OperatingSystem.IsWindows() && startupConfig.UseUnixSocket())
|
||||
{
|
||||
@@ -180,7 +191,7 @@ namespace Jellyfin.Server
|
||||
|
||||
_logger.LogInformation("Startup complete {Time:g}", Stopwatch.GetElapsedTime(_startTimestamp));
|
||||
|
||||
await host.WaitForShutdownAsync().ConfigureAwait(false);
|
||||
await _jfHost.WaitForShutdownAsync().ConfigureAwait(false);
|
||||
_restartOnShutdown = appHost.ShouldRestart;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -205,7 +216,7 @@ namespace Jellyfin.Server
|
||||
}
|
||||
}
|
||||
|
||||
host?.Dispose();
|
||||
_jfHost?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user