diff options
| author | dkanada <dkanada@users.noreply.github.com> | 2019-08-19 01:59:07 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-19 01:59:07 -0700 |
| commit | c8474f734c779d61444a6e48de9ff7825d7904c9 (patch) | |
| tree | 26d2255abca595f1dc1214b8318b483439015d2f | |
| parent | 5626709de599fc26bba04356dfa28cc579d4b989 (diff) | |
| parent | 99aea27723dc7acc2beb14393eae89a3d2bd860f (diff) | |
Merge pull request #1644 from Bond-009/hiddenwarn
Fix possible hidden exceptions
| -rw-r--r-- | Jellyfin.Server/Program.cs | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index 5e4e36a34..594441af0 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -150,14 +150,15 @@ namespace Jellyfin.Server _logger.LogWarning("Failed to enable shared cache for SQLite"); } - using (var appHost = new CoreAppHost( + var appHost = new CoreAppHost( appPaths, _loggerFactory, options, new ManagedFileSystem(_loggerFactory.CreateLogger<ManagedFileSystem>(), appPaths), new NullImageEncoder(), new NetworkManager(_loggerFactory.CreateLogger<NetworkManager>()), - appConfig)) + appConfig); + try { await appHost.InitAsync(new ServiceCollection()).ConfigureAwait(false); @@ -165,15 +166,20 @@ namespace Jellyfin.Server await appHost.RunStartupTasksAsync().ConfigureAwait(false); - try - { - // Block main thread until shutdown - await Task.Delay(-1, _tokenSource.Token).ConfigureAwait(false); - } - catch (TaskCanceledException) - { - // Don't throw on cancellation - } + // Block main thread until shutdown + await Task.Delay(-1, _tokenSource.Token).ConfigureAwait(false); + } + catch (TaskCanceledException) + { + // Don't throw on cancellation + } + catch (Exception ex) + { + _logger.LogCritical(ex, "Error while starting server."); + } + finally + { + appHost?.Dispose(); } if (_restartOnShutdown) |
