diff options
Diffstat (limited to 'Jellyfin.Server/Program.cs')
| -rw-r--r-- | Jellyfin.Server/Program.cs | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index 93f71fdc69..12f92efb35 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -133,11 +133,13 @@ namespace Jellyfin.Server } } + SetupServer.ReportActivity(StartupActivity.CheckingStorage); StorageHelper.TestCommonPathsForStorageCapacity(appPaths, StartupLogger.Logger.With(_loggerFactory.CreateLogger<Startup>()).BeginGroup($"Storage Check")); StartupHelpers.PerformStaticInitialization(); - await ApplyStartupMigrationAsync(appPaths, startupConfig).ConfigureAwait(false); + SetupServer.ReportActivity(StartupActivity.Initializing); + await ApplyStartupMigrationAsync(appPaths, startupConfig, options).ConfigureAwait(false); do { @@ -161,7 +163,6 @@ namespace Jellyfin.Server _loggerFactory, options, startupConfig); - _appHost = appHost; var configurationCompleted = false; try { @@ -196,6 +197,7 @@ namespace Jellyfin.Server if (!string.IsNullOrWhiteSpace(_restoreFromBackup)) { + SetupServer.ReportActivity(StartupActivity.RestoringBackup); await appHost.ServiceProvider.GetService<IBackupService>()!.RestoreBackupAsync(_restoreFromBackup).ConfigureAwait(false); _restoreFromBackup = null; _restartOnShutdown = true; @@ -203,10 +205,15 @@ namespace Jellyfin.Server } var jellyfinMigrationService = ActivatorUtilities.CreateInstance<JellyfinMigrationService>(appHost.ServiceProvider); + SetupServer.ReportActivity(StartupActivity.PreparingMigrations); await jellyfinMigrationService.PrepareSystemForMigration(_logger).ConfigureAwait(false); + // "Preparing migrations" carries through the DB read; per-migration progress is reported + // as "Running migration X of Y" from inside the step once the pending set is known. await jellyfinMigrationService.MigrateStepAsync(JellyfinMigrationStageTypes.CoreInitialisation, appHost.ServiceProvider).ConfigureAwait(false); + SetupServer.ReportActivity(StartupActivity.InitializingServices); await appHost.InitializeServices(startupConfig).ConfigureAwait(false); + _appHost = appHost; await jellyfinMigrationService.MigrateStepAsync(JellyfinMigrationStageTypes.AppInitialisation, appHost.ServiceProvider).ConfigureAwait(false); await jellyfinMigrationService.CleanupSystemAfterMigration(_logger).ConfigureAwait(false); @@ -214,13 +221,17 @@ namespace Jellyfin.Server { configurationCompleted = true; await _setupServer!.StopAsync().ConfigureAwait(false); - await _jellyfinHost.StartAsync().ConfigureAwait(false); - if (!OperatingSystem.IsWindows() && startupConfig.UseUnixSocket()) + if (options.StartupMode is null or Configuration.StartupMode.MediaServer) { - var socketPath = StartupHelpers.GetUnixSocketPath(startupConfig, appPaths); + await _jellyfinHost.StartAsync().ConfigureAwait(false); - StartupHelpers.SetUnixSocketPermissions(startupConfig, socketPath, _logger); + if (!OperatingSystem.IsWindows() && startupConfig.UseUnixSocket()) + { + var socketPath = StartupHelpers.GetUnixSocketPath(startupConfig, appPaths); + + StartupHelpers.SetUnixSocketPermissions(startupConfig, socketPath, _logger); + } } } catch (Exception) @@ -229,11 +240,14 @@ namespace Jellyfin.Server throw; } - await appHost.RunStartupTasksAsync().ConfigureAwait(false); + if (options.StartupMode is null or Configuration.StartupMode.MediaServer) + { + await appHost.RunStartupTasksAsync().ConfigureAwait(false); + _logger.LogInformation("Startup complete {Time:g}", Stopwatch.GetElapsedTime(_startTimestamp)); - _logger.LogInformation("Startup complete {Time:g}", Stopwatch.GetElapsedTime(_startTimestamp)); + await _jellyfinHost.WaitForShutdownAsync().ConfigureAwait(false); + } - await _jellyfinHost.WaitForShutdownAsync().ConfigureAwait(false); _restartOnShutdown = appHost.ShouldRestart; _restoreFromBackup = appHost.RestoreBackupPath; } @@ -244,7 +258,11 @@ namespace Jellyfin.Server if (_setupServer!.IsAlive && !configurationCompleted) { _setupServer!.SoftStop(); - await Task.Delay(TimeSpan.FromMinutes(10)).ConfigureAwait(false); + if (options.StartupMode is null or Configuration.StartupMode.MediaServer) + { + await Task.Delay(TimeSpan.FromMinutes(10)).ConfigureAwait(false); + } + await _setupServer!.StopAsync().ConfigureAwait(false); } } @@ -263,6 +281,7 @@ namespace Jellyfin.Server _appHost = null; _jellyfinHost?.Dispose(); + _jellyfinHost = null; } } @@ -274,8 +293,9 @@ namespace Jellyfin.Server /// </remarks> /// <param name="appPaths">Application Paths.</param> /// <param name="startupConfig">Startup Config.</param> + /// <param name="startupOptions">The applications startup options.</param> /// <returns>A task.</returns> - public static async Task ApplyStartupMigrationAsync(ServerApplicationPaths appPaths, IConfiguration startupConfig) + public static async Task ApplyStartupMigrationAsync(ServerApplicationPaths appPaths, IConfiguration startupConfig, StartupOptions startupOptions) { _migrationLogger = StartupLogger.Logger.BeginGroup<JellyfinMigrationService>($"Migration Service"); var startupConfigurationManager = new ServerConfigurationManager(appPaths, _loggerFactory, new MyXmlSerializer()); @@ -293,7 +313,7 @@ namespace Jellyfin.Server PrepareDatabaseProvider(startupService); var jellyfinMigrationService = ActivatorUtilities.CreateInstance<JellyfinMigrationService>(startupService); - await jellyfinMigrationService.CheckFirstTimeRunOrMigration(appPaths).ConfigureAwait(false); + await jellyfinMigrationService.CheckFirstTimeRunOrMigration(appPaths, startupOptions).ConfigureAwait(false); await jellyfinMigrationService.MigrateStepAsync(Migrations.Stages.JellyfinMigrationStageTypes.PreInitialisation, startupService).ConfigureAwait(false); } |
