From fda26e1f153e891c7f4d83c9708238446f9bd099 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 3 Nov 2023 02:07:11 -0400 Subject: [PATCH] Fix issue with DMAPI validation shutdown timeouts - Increase grace period to 30s to avoid false positives. --- src/DMAPI/tgs/core/datum.dm | 1 + .../Components/Session/SessionController.cs | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/DMAPI/tgs/core/datum.dm b/src/DMAPI/tgs/core/datum.dm index 8d402c9cfe..07ce3b6845 100644 --- a/src/DMAPI/tgs/core/datum.dm +++ b/src/DMAPI/tgs/core/datum.dm @@ -16,6 +16,7 @@ TGS_DEFINE_AND_SET_GLOBAL(tgs, null) TGS_DEBUG_LOG("About to terminate world. Tick: [world.time], sleep_offline: [world.sleep_offline]") world.sleep_offline = FALSE // https://www.byond.com/forum/post/2894866 del(world) + world.sleep_offline = FALSE // just in case, this is BYOND after all... sleep(1) TGS_DEBUG_LOG("BYOND DIDN'T TERMINATE THE WORLD!!! TICK IS: [world.time], sleep_offline: [world.sleep_offline]") diff --git a/src/Tgstation.Server.Host/Components/Session/SessionController.cs b/src/Tgstation.Server.Host/Components/Session/SessionController.cs index 01ddcea2d4..bf0d22fac7 100644 --- a/src/Tgstation.Server.Host/Components/Session/SessionController.cs +++ b/src/Tgstation.Server.Host/Components/Session/SessionController.cs @@ -689,10 +689,12 @@ namespace Tgstation.Server.Host.Components.Session return; } - Logger.LogDebug("Server will terminated in 10s if it does not exit..."); - var delayTask = asyncDelayer.Delay(TimeSpan.FromSeconds(10), CancellationToken.None); // DCT: None available - var completedTask = await Task.WhenAny(process.Lifetime, delayTask); - if (completedTask == delayTask) + const int GracePeriodSeconds = 30; + Logger.LogDebug("Server will terminated in {gracePeriodSeconds}s if it does not exit...", GracePeriodSeconds); + var delayTask = asyncDelayer.Delay(TimeSpan.FromSeconds(GracePeriodSeconds), CancellationToken.None); // DCT: None available + await Task.WhenAny(process.Lifetime, delayTask); + + if (!process.Lifetime.IsCompleted) { Logger.LogWarning("DMAPI took too long to shutdown server after validation request!"); process.Terminate();