From e08d5ede1a117ff6bef57fcabd5bb2c2bcee7b07 Mon Sep 17 00:00:00 2001 From: Dominion Date: Sun, 2 Apr 2023 21:48:57 -0400 Subject: [PATCH] Safer instance manager shutdown --- .../Components/InstanceManager.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/InstanceManager.cs b/src/Tgstation.Server.Host/Components/InstanceManager.cs index d776370de2..ac0b1d230b 100644 --- a/src/Tgstation.Server.Host/Components/InstanceManager.cs +++ b/src/Tgstation.Server.Host/Components/InstanceManager.cs @@ -461,14 +461,27 @@ namespace Tgstation.Server.Host.Components logger.LogDebug("Stopping instance manager..."); var instanceFactoryStopTask = instanceFactory.StopAsync(cancellationToken); await jobManager.StopAsync(cancellationToken); - await Task.WhenAll(instances.Select(x => x.Value.Instance.StopAsync(cancellationToken))); + + async Task OfflineInstanceImmediate(IInstance instance, CancellationToken cancellationToken) + { + try + { + await instance.StopAsync(cancellationToken); + } + catch (Exception ex) + { + logger.LogError(ex, "Instance shutdown exception!"); + } + } + + await Task.WhenAll(instances.Select(x => OfflineInstanceImmediate(x.Value.Instance, cancellationToken))); await instanceFactoryStopTask; await swarmService.Shutdown(cancellationToken); } catch (Exception ex) { - logger.LogError(ex, "Instance manager stop exception!"); + logger.LogCritical(ex, "Instance manager stop exception!"); } }