diff --git a/src/Tgstation.Server.Host/Components/Watchdog/SessionController.cs b/src/Tgstation.Server.Host/Components/Watchdog/SessionController.cs index a0ca37eb8d..7f62840d90 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/SessionController.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/SessionController.cs @@ -447,6 +447,15 @@ namespace Tgstation.Server.Host.Components.Watchdog async Task SendCommand(string command, ushort? overridePort, CancellationToken cancellationToken) { + if (Lifetime.IsCompleted) + { + logger.LogWarning( + "Attempted to send a command to an inactive SessionController{1}: {0}", + command, + overridePort.HasValue ? $" (Override port: {overridePort.Value})" : String.Empty); + return null; + } + try { var commandString = String.Format(CultureInfo.InvariantCulture, diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs index 336021687c..8b962e9936 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs @@ -426,6 +426,9 @@ namespace Tgstation.Server.Host.Components.Watchdog /// public async Task HandleEvent(EventType eventType, IEnumerable parameters, CancellationToken cancellationToken) { + if (!Running) + return true; + string results; using (await SemaphoreSlimContext.Lock(Semaphore, cancellationToken).ConfigureAwait(false)) {