From b37ddfe1bc88204c535b9e5b8de0d16f987cbd81 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 20 Sep 2018 10:45:53 -0400 Subject: [PATCH] Fix restarts triggering when the same launch parameters are reloaded --- .../Internal/DreamDaemonLaunchParameters.cs | 15 ++++++++++++++- .../Components/Watchdog/Watchdog.cs | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Api/Models/Internal/DreamDaemonLaunchParameters.cs b/src/Tgstation.Server.Api/Models/Internal/DreamDaemonLaunchParameters.cs index b1f3496329..5e79d35cff 100644 --- a/src/Tgstation.Server.Api/Models/Internal/DreamDaemonLaunchParameters.cs +++ b/src/Tgstation.Server.Api/Models/Internal/DreamDaemonLaunchParameters.cs @@ -1,4 +1,5 @@ -using System.ComponentModel.DataAnnotations; +using System; +using System.ComponentModel.DataAnnotations; namespace Tgstation.Server.Api.Models.Internal { @@ -36,5 +37,17 @@ namespace Tgstation.Server.Api.Models.Internal /// [Required] public uint? StartupTimeout { get; set; } + + /// + /// Check if we match a given set of + /// + /// The to compare against + /// if they match, otherwise + public bool Match(DreamDaemonLaunchParameters otherParameters) => + AllowWebClient == otherParameters.AllowWebClient + && SecurityLevel == otherParameters.SecurityLevel + && PrimaryPort == otherParameters.PrimaryPort + && SecondaryPort == otherParameters.SecondaryPort + && StartupTimeout == otherParameters.StartupTimeout; } } \ No newline at end of file diff --git a/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs index 412612e49c..6bee502b02 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs @@ -617,6 +617,8 @@ namespace Tgstation.Server.Host.Components.Watchdog { using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken).ConfigureAwait(false)) { + if (launchParameters.Match(ActiveLaunchParameters)) + return; ActiveLaunchParameters = launchParameters; if (Running) //queue an update @@ -780,6 +782,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// public async Task Restart(bool graceful, CancellationToken cancellationToken) { + logger.LogTrace("Begin Restart. Graceful: {0}", graceful); using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken).ConfigureAwait(false)) { if (!graceful || !Running)