Fix chat message for exit code 0 sessions

This commit is contained in:
Jordan Dominion
2024-01-24 20:06:23 -05:00
parent 97dcd9729d
commit d0cb99bd70
3 changed files with 10 additions and 5 deletions
@@ -22,7 +22,7 @@ namespace Tgstation.Server.Host.Components.Session
/// <summary>
/// If the DreamDaemon instance sent a.
/// </summary>
bool TerminationWasRequested { get; }
bool TerminationWasIntentional { get; }
/// <summary>
/// The DMAPI <see cref="Session.ApiValidationStatus"/>.
@@ -63,7 +63,7 @@ namespace Tgstation.Server.Host.Components.Session
public Version? DMApiVersion { get; private set; }
/// <inheritdoc />
public bool TerminationWasRequested { get; private set; }
public bool TerminationWasIntentional => terminationWasIntentional || (Lifetime.IsCompleted && Lifetime.Result == 0);
/// <inheritdoc />
public Task<LaunchResult> LaunchResult { get; }
@@ -219,6 +219,11 @@ namespace Tgstation.Server.Host.Components.Session
/// </summary>
bool released;
/// <summary>
/// Backing field for overriding <see cref="TerminationWasIntentional"/>.
/// </summary>
bool terminationWasIntentional;
/// <summary>
/// Initializes a new instance of the <see cref="SessionController"/> class.
/// </summary>
@@ -622,7 +627,7 @@ namespace Tgstation.Server.Host.Components.Session
case BridgeCommandType.Kill:
Logger.LogInformation("Bridge requested process termination!");
chatTrackingContext.Active = false;
TerminationWasRequested = true;
terminationWasIntentional = true;
process.Terminate();
break;
case BridgeCommandType.DeprecatedPortUpdate:
@@ -113,12 +113,12 @@ namespace Tgstation.Server.Host.Components.Watchdog
switch (reason)
{
case MonitorActivationReason.ActiveServerCrashed:
var eventType = controller.TerminationWasRequested || (await controller.Lifetime) == 0
var eventType = controller.TerminationWasIntentional
? EventType.WorldEndProcess
: EventType.WatchdogCrash;
await HandleEventImpl(eventType, Enumerable.Empty<string>(), false, cancellationToken);
var exitWord = controller.TerminationWasRequested ? "exited" : "crashed";
var exitWord = controller.TerminationWasIntentional ? "exited" : "crashed";
if (controller.RebootState == Session.RebootState.Shutdown)
{
// the time for graceful shutdown is now