Fix possible hidden exceptions
If an error occurred while starting the server which in turn caused an exception in the dispose method of the apphost, the first exception wouldn't get logged.
This commit is contained in:
parent
4bb0c2d053
commit
99aea27723
|
@ -150,14 +150,15 @@ namespace Jellyfin.Server
|
||||||
_logger.LogWarning("Failed to enable shared cache for SQLite");
|
_logger.LogWarning("Failed to enable shared cache for SQLite");
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var appHost = new CoreAppHost(
|
var appHost = new CoreAppHost(
|
||||||
appPaths,
|
appPaths,
|
||||||
_loggerFactory,
|
_loggerFactory,
|
||||||
options,
|
options,
|
||||||
new ManagedFileSystem(_loggerFactory.CreateLogger<ManagedFileSystem>(), appPaths),
|
new ManagedFileSystem(_loggerFactory.CreateLogger<ManagedFileSystem>(), appPaths),
|
||||||
new NullImageEncoder(),
|
new NullImageEncoder(),
|
||||||
new NetworkManager(_loggerFactory.CreateLogger<NetworkManager>()),
|
new NetworkManager(_loggerFactory.CreateLogger<NetworkManager>()),
|
||||||
appConfig))
|
appConfig);
|
||||||
|
try
|
||||||
{
|
{
|
||||||
await appHost.InitAsync(new ServiceCollection()).ConfigureAwait(false);
|
await appHost.InitAsync(new ServiceCollection()).ConfigureAwait(false);
|
||||||
|
|
||||||
|
@ -165,15 +166,20 @@ namespace Jellyfin.Server
|
||||||
|
|
||||||
await appHost.RunStartupTasksAsync().ConfigureAwait(false);
|
await appHost.RunStartupTasksAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
try
|
// Block main thread until shutdown
|
||||||
{
|
await Task.Delay(-1, _tokenSource.Token).ConfigureAwait(false);
|
||||||
// Block main thread until shutdown
|
}
|
||||||
await Task.Delay(-1, _tokenSource.Token).ConfigureAwait(false);
|
catch (TaskCanceledException)
|
||||||
}
|
{
|
||||||
catch (TaskCanceledException)
|
// Don't throw on cancellation
|
||||||
{
|
}
|
||||||
// Don't throw on cancellation
|
catch (Exception ex)
|
||||||
}
|
{
|
||||||
|
_logger.LogCritical(ex, "Error while starting server.");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
appHost?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_restartOnShutdown)
|
if (_restartOnShutdown)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user