From b03648f40e4efd747646ffd50146795eae312cda Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 27 Sep 2018 09:36:30 -0400 Subject: [PATCH] Remove InactiveServerHasStagedDmb from MonitorState It was purely informational and we can do better by just logging CompileJob IDs --- .../Components/Watchdog/MonitorState.cs | 5 ---- .../Components/Watchdog/Watchdog.cs | 26 +++++++------------ 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/MonitorState.cs b/src/Tgstation.Server.Host/Components/Watchdog/MonitorState.cs index cb2264c96f..571874a370 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/MonitorState.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/MonitorState.cs @@ -12,11 +12,6 @@ namespace Tgstation.Server.Host.Components.Watchdog /// public bool RebootingInactiveServer { get; set; } - /// - /// If the inactive server has a .dmb and needs to be swapped in - /// - public bool InactiveServerHasStagedDmb { get; set; } - /// /// If the inactive server is in an unrecoverable state /// diff --git a/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs index 5f366555f5..0aa6066494 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs @@ -349,16 +349,13 @@ namespace Tgstation.Server.Host.Components.Watchdog //replace the notification tcs here so that the next loop will read a fresh one activeParametersUpdated = new TaskCompletionSource(); monitorState.InactiveServer.Dispose(); //kill or recycle it - monitorState.NextAction = breakAfter ? MonitorAction.Break : MonitorAction.Continue; + var desiredNextAction = breakAfter ? MonitorAction.Break : MonitorAction.Continue; + monitorState.NextAction = desiredNextAction; - var usedLatestDmb = await RestartInactiveServer().ConfigureAwait(false); + await RestartInactiveServer().ConfigureAwait(false); - if (monitorState.NextAction == (breakAfter ? MonitorAction.Break : MonitorAction.Continue)) - { + if (monitorState.NextAction == desiredNextAction) monitorState.ActiveServer.ClosePortOnReboot = false; - if (monitorState.InactiveServerHasStagedDmb && !usedLatestDmb) - monitorState.InactiveServerHasStagedDmb = false; //don't try to load it again though - } }; string ExitWord(ISessionController controller) => controller.TerminationWasRequested ? "exited" : "crashed"; @@ -433,10 +430,6 @@ namespace Tgstation.Server.Host.Components.Watchdog //are both servers now running the same CompileJob? var sameCompileJob = monitorState.InactiveServer.Dmb.CompileJob.Id == monitorState.ActiveServer.Dmb.CompileJob.Id; - if (sameCompileJob && monitorState.InactiveServerHasStagedDmb) - //both servers now up to date - monitorState.InactiveServerHasStagedDmb = false; - if (!sameCompileJob || ActiveLaunchParameters != LastLaunchParameters) //need a new launch to update either settings or compile job restartOnceSwapped = true; @@ -499,9 +492,6 @@ namespace Tgstation.Server.Host.Components.Watchdog monitorState.NextAction = MonitorAction.Continue; break; case MonitorActivationReason.NewDmbAvailable: - //set this and then its the same a settings change - monitorState.InactiveServerHasStagedDmb = true; - goto case MonitorActivationReason.ActiveLaunchParametersUpdated; case MonitorActivationReason.ActiveLaunchParametersUpdated: //just reload the inactive server and wait for a swap to apply the changes await UpdateAndRestartInactiveServer(true).ConfigureAwait(false); @@ -534,9 +524,8 @@ namespace Tgstation.Server.Host.Components.Watchdog logger.LogDebug("Alpha is the active server"); else logger.LogDebug("Bravo is the active server"); - - if (monitorState.InactiveServerHasStagedDmb) - logger.LogDebug("Inactive server has staged .dmb"); + + if (monitorState.RebootingInactiveServer) logger.LogDebug("Inactive server is rebooting"); @@ -549,6 +538,9 @@ namespace Tgstation.Server.Host.Components.Watchdog if (monitorState.InactiveServer.ClosePortOnReboot) logger.LogDebug("Inactive server will close port on reboot"); + logger.LogDebug("Active server Compile Job ID: {0}", monitorState.ActiveServer.Dmb.CompileJob.Id); + logger.LogDebug("Inactive server Compile Job ID: {0}", monitorState.InactiveServer.Dmb.CompileJob.Id); + //load the activation tasks into local variables var activeServerLifetime = monitorState.ActiveServer.Lifetime; var inactiveServerLifetime = monitorState.InactiveServer.Lifetime;