From 932a64a0f55ced157b0784052baeb9fe8cd7c50a Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Tue, 30 Jun 2020 04:13:34 -0400 Subject: [PATCH] Don't say `Startup Failed` when monitor restarting --- .../Components/Watchdog/WatchdogBase.cs | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs index a429411b0d..8dc3e9ab9f 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs @@ -130,7 +130,7 @@ namespace Tgstation.Server.Host.Components.Watchdog readonly object controllerDisposeLock; /// - /// If the should in + /// If the should in /// readonly bool autoStart; @@ -346,10 +346,16 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// If should be started by this function /// If the launch should be announced to chat by this function + /// If launch failure should be announced to chat by this function. /// to use, if any /// The for the operation /// A representing the running operation - protected async Task LaunchNoLock(bool startMonitor, bool announce, ReattachInformation reattachInfo, CancellationToken cancellationToken) + protected async Task LaunchNoLock( + bool startMonitor, + bool announce, + bool announceFailure, + ReattachInformation reattachInfo, + CancellationToken cancellationToken) { Logger.LogTrace("Begin LaunchImplNoLock"); @@ -389,7 +395,8 @@ namespace Tgstation.Server.Host.Components.Watchdog async Task ChainChatTaskWithErrorMessage() { await originalChatTask.ConfigureAwait(false); - await Chat.SendWatchdogMessage("Startup failed!", false, cancellationToken).ConfigureAwait(false); + if (announceFailure) + await Chat.SendWatchdogMessage("Startup failed!", false, cancellationToken).ConfigureAwait(false); } announceTask = ChainChatTaskWithErrorMessage(); @@ -531,7 +538,7 @@ namespace Tgstation.Server.Host.Components.Watchdog try { // use LaunchImplNoLock without announcements or restarting the monitor - await LaunchNoLock(false, false, null, cancellationToken).ConfigureAwait(false); + await LaunchNoLock(false, false, false, null, cancellationToken).ConfigureAwait(false); Logger.LogDebug("Relaunch successful, resuming monitor..."); return; } @@ -818,7 +825,7 @@ namespace Tgstation.Server.Host.Components.Watchdog if (Status != WatchdogStatus.Offline) throw new JobException(ErrorCode.WatchdogRunning); using (await SemaphoreSlimContext.Lock(Semaphore, cancellationToken).ConfigureAwait(false)) - await LaunchNoLock(true, true, null, cancellationToken).ConfigureAwait(false); + await LaunchNoLock(true, true, true, null, cancellationToken).ConfigureAwait(false); } /// @@ -847,7 +854,7 @@ namespace Tgstation.Server.Host.Components.Watchdog { var chatTask = Chat.SendWatchdogMessage("Manual restart triggered...", false, cancellationToken); await TerminateNoLock(false, false, cancellationToken).ConfigureAwait(false); - await LaunchNoLock(true, false, null, cancellationToken).ConfigureAwait(false); + await LaunchNoLock(true, false, true, null, cancellationToken).ConfigureAwait(false); await chatTask.ConfigureAwait(false); return; } @@ -894,7 +901,7 @@ namespace Tgstation.Server.Host.Components.Watchdog await jobManager.RegisterOperation(job, async (j, databaseContextFactory, progressFunction, ct) => { using (await SemaphoreSlimContext.Lock(Semaphore, ct).ConfigureAwait(false)) - await LaunchNoLock(true, true, reattachInfo, ct).ConfigureAwait(false); + await LaunchNoLock(true, true, true, reattachInfo, ct).ConfigureAwait(false); }, cancellationToken).ConfigureAwait(false); }