From a447dd323dcf07b57c7b79b590ccefc7f485712d Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Sun, 10 Jan 2021 14:06:02 +0000 Subject: [PATCH] V2 --- src/Tgstation.Server.Host/Components/Events/EventType.cs | 8 +++++++- .../Components/Watchdog/BasicWatchdog.cs | 4 ++++ .../Components/Watchdog/WatchdogBase.cs | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Events/EventType.cs b/src/Tgstation.Server.Host/Components/Events/EventType.cs index 9085c6e215..4e20113171 100644 --- a/src/Tgstation.Server.Host/Components/Events/EventType.cs +++ b/src/Tgstation.Server.Host/Components/Events/EventType.cs @@ -111,6 +111,12 @@ namespace Tgstation.Server.Host.Components.Events /// Before the watchdog launches. No parameters. /// [EventScript("WatchdogLaunch")] - WatchdogLaunch + WatchdogLaunch, + + /// + /// Inbetween DD restarts if the process has been force-ended by the DMAPI (TgsEndProcess()) + /// + [EventScript("WorldEndProcess")] + WorldEndProcess, } } diff --git a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs index c364a8cf65..4a83eab388 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using System; using System.Globalization; +using System.Linq; using System.Threading; using System.Threading.Tasks; using Tgstation.Server.Api.Models.Internal; @@ -91,6 +92,9 @@ namespace Tgstation.Server.Host.Components.Watchdog switch (reason) { case MonitorActivationReason.ActiveServerCrashed: + if (Server.TerminationWasRequested) + await eventConsumer.HandleEvent(EventType.WorldEndProcess, Enumerable.Empty(), cancellationToken).ConfigureAwait(false); + string exitWord = Server.TerminationWasRequested ? "exited" : "crashed"; if (Server.RebootState == Session.RebootState.Shutdown) { diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs index 5a24b01076..e1c8336752 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs @@ -121,7 +121,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// The that is not the /// - readonly IEventConsumer eventConsumer; + public IEventConsumer eventConsumer; /// /// The for the .