From 6b1aad68e07996fb895557f4584076de89ba2d25 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 23 Jun 2023 09:02:07 -0400 Subject: [PATCH] Code deduplication --- src/Tgstation.Server.Host/System/SystemDManager.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/System/SystemDManager.cs b/src/Tgstation.Server.Host/System/SystemDManager.cs index a026be25fb..44ea899b3f 100644 --- a/src/Tgstation.Server.Host/System/SystemDManager.cs +++ b/src/Tgstation.Server.Host/System/SystemDManager.cs @@ -19,6 +19,11 @@ namespace Tgstation.Server.Host.System /// sealed class SystemDManager : IHostedService, IRestartHandler, IDisposable { + /// + /// The sd_notify command for notifying the watchdog we are alive. + /// + const string SDNotifyWatchdog = "WATCHDOG=1"; + /// /// The for the . /// @@ -104,7 +109,7 @@ namespace Tgstation.Server.Host.System /// public Task StartAsync(CancellationToken cancellationToken) { - if (SendSDNotify("WATCHDOG=1")) + if (SendSDNotify(SDNotifyWatchdog)) { logger.LogDebug("SystemD detected"); runTask = RunAsync(watchdogCts.Token); @@ -176,10 +181,7 @@ namespace Tgstation.Server.Host.System { await Task.Delay(milliseconds, cancellationToken); - logger.LogTrace("Sending sd_notify WATCHDOG=1"); - var result = NativeMethods.sd_notify(0, "WATCHDOG=1"); - if (result <= 0) - logger.LogError(new UnixIOException(result), "sd_notify READY=1 failed!"); + SendSDNotify(SDNotifyWatchdog); } } catch (OperationCanceledException ex)