Add a seperate event for unexpected DreamDaemon exits

This commit is contained in:
Jordan Brown
2021-01-14 13:35:47 -05:00
parent a04b1cccf7
commit afcdafa564
3 changed files with 15 additions and 6 deletions
+4 -3
View File
@@ -97,10 +97,11 @@
#define TGS_EVENT_WATCHDOG_DETACH 16
// We don't actually implement these 3 events as the DMAPI can never receive them.
// #define TGS_EVENT_WATCHDOG_LAUNCH 17
// #define TGS_EVENT_WORLD_END_PROCESS 18
// #define TGS_EVENT_WORLD_DEL 19
// #define TGS_EVENT_WATCHDOG_CRASH 18
// #define TGS_EVENT_WORLD_END_PROCESS 19
// #define TGS_EVENT_WORLD_DEL 20
/// Watchdog event when TgsInitializationComplete() is called. No parameters.
#define TGS_EVENT_WORLD_PRIME 20
#define TGS_EVENT_WORLD_PRIME 21
// OTHER ENUMS
@@ -113,6 +113,12 @@ namespace Tgstation.Server.Host.Components.Events
[EventScript("WatchdogLaunch")]
WatchdogLaunch,
/// <summary>
/// Watchdog event when DreamDaemon exits unexpectedly. No parameters.
/// </summary>
[EventScript("WatchdogLaunch")]
WatchdogCrash,
/// <summary>
/// In between watchdog DreamDaemon restarts if the process has been force-ended by the DMAPI (TgsEndProcess()). No parameters.
/// </summary>
@@ -92,10 +92,12 @@ namespace Tgstation.Server.Host.Components.Watchdog
switch (reason)
{
case MonitorActivationReason.ActiveServerCrashed:
if (Server.TerminationWasRequested)
await EventConsumer.HandleEvent(EventType.WorldEndProcess, Enumerable.Empty<string>(), cancellationToken).ConfigureAwait(false);
var eventType = Server.TerminationWasRequested
? EventType.WorldEndProcess
: EventType.WatchdogCrash;
await EventConsumer.HandleEvent(eventType, Enumerable.Empty<string>(), cancellationToken).ConfigureAwait(false);
string exitWord = Server.TerminationWasRequested ? "exited" : "crashed";
var exitWord = Server.TerminationWasRequested ? "exited" : "crashed";
if (Server.RebootState == Session.RebootState.Shutdown)
{
// the time for graceful shutdown is now