diff options
| author | Shadowghost <Shadowghost@users.noreply.github.com> | 2026-10-05 19:18:42 -0400 |
|---|---|---|
| committer | Cody Robibero <cody@robibe.ro> | 2026-10-05 19:18:42 -0400 |
| commit | 6c753e8d71c21d20c7967a5583f139171c94c845 (patch) | |
| tree | b8d28a223291b1d180c9bbae9a1c1b6578e2cd1f | |
| parent | e7764cbbd9db5e20ce764121d550b732405100e3 (diff) | |
Backport pull request #18063 from jellyfin/release-12.z
Don't let a failed shutdown cancel an in-process restart
Original-merge: 344c5297a3382164e1bdcb311416fd119271ed68
Merged-by: crobibero <cody@robibe.ro>
Backported-by: Cody Robibero <cody@robibe.ro>
| -rw-r--r-- | Jellyfin.Server/Program.cs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index 715fc3d3b9..29c7d512d0 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -149,8 +149,16 @@ namespace Jellyfin.Server if (_restartOnShutdown) { _startTimestamp = Stopwatch.GetTimestamp(); - await _setupServer.StopAsync().ConfigureAwait(false); - await _setupServer.RunAsync().ConfigureAwait(false); + try + { + await _setupServer.StopAsync().ConfigureAwait(false); + await _setupServer.RunAsync().ConfigureAwait(false); + } + catch (Exception ex) + { + // The startup page is optional, losing it must not take the restart down with it. + _logger.LogError(ex, "Failed to bring the startup server back up"); + } } } while (_restartOnShutdown); @@ -245,7 +253,15 @@ namespace Jellyfin.Server await appHost.RunStartupTasksAsync().ConfigureAwait(false); _logger.LogInformation("Startup complete {Time:g}", Stopwatch.GetElapsedTime(_startTimestamp)); - await _jellyfinHost.WaitForShutdownAsync().ConfigureAwait(false); + try + { + await _jellyfinHost.WaitForShutdownAsync().ConfigureAwait(false); + } + catch (Exception ex) + { + // A hosted service that throws or times out while stopping must not cancel a pending restart. + _logger.LogError(ex, "Failure while stopping the server"); + } } _restartOnShutdown = appHost.ShouldRestart; |
