Allow heartbeat time to be changed without a reboot

This commit is contained in:
Cyberboss
2020-05-31 15:46:19 -04:00
parent 92b63db42e
commit 3ca2a8d248
2 changed files with 8 additions and 10 deletions
@@ -52,11 +52,10 @@ namespace Tgstation.Server.Api.Models.Internal
/// </summary>
/// <param name="otherParameters">The <see cref="DreamDaemonLaunchParameters"/> to compare against</param>
/// <returns><see langword="true"/> if they match, <see langword="false"/> otherwise</returns>
public bool Match(DreamDaemonLaunchParameters otherParameters) =>
public bool CanApplyWithoutReboot(DreamDaemonLaunchParameters otherParameters) =>
AllowWebClient == (otherParameters?.AllowWebClient ?? throw new ArgumentNullException(nameof(otherParameters)))
&& SecurityLevel == otherParameters.SecurityLevel
&& PrimaryPort == otherParameters.PrimaryPort
&& SecondaryPort == otherParameters.SecondaryPort
&& HeartbeatSeconds == otherParameters.HeartbeatSeconds; // We intentionally don't check StartupTimeout as it doesn't matter
&& SecondaryPort == otherParameters.SecondaryPort; // We intentionally don't check StartupTimeout or heartbeat seconds as it doesn't matter in terms of the watchdog
}
}
@@ -743,14 +743,13 @@ namespace Tgstation.Server.Host.Components.Watchdog
{
using (await SemaphoreSlimContext.Lock(Semaphore, cancellationToken).ConfigureAwait(false))
{
if (launchParameters.Match(ActiveLaunchParameters))
return;
bool match = launchParameters.CanApplyWithoutReboot(ActiveLaunchParameters);
ActiveLaunchParameters = launchParameters;
if (Running)
{
ActiveParametersUpdated.TrySetResult(null); // queue an update
ActiveParametersUpdated = new TaskCompletionSource<object>();
}
if (match || !Running)
return;
ActiveParametersUpdated.TrySetResult(null); // queue an update
ActiveParametersUpdated = new TaskCompletionSource<object>();
}
}