Adds IWatchdog.ResetRebootState

This commit is contained in:
Jordan Brown
2018-09-16 10:27:28 -04:00
parent ca10551722
commit 41e38211cf
2 changed files with 20 additions and 2 deletions
@@ -76,5 +76,12 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task"/> representing the running operation</returns>
Task Terminate(bool graceful, CancellationToken cancellationToken);
/// <summary>
/// Cancels pending graceful actions
/// </summary>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task"/> representing the running operation</returns>
Task ResetRebootState(CancellationToken cancellationToken);
}
}
@@ -764,6 +764,19 @@ namespace Tgstation.Server.Host.Components.Watchdog
return await LaunchNoLock(true, true, false, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc />
public async Task ResetRebootState(CancellationToken cancellationToken)
{
using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
{
if (!Running)
return;
var toClear = AlphaIsActive ? alphaServer : bravoServer;
if (toClear != null)
toClear.ResetRebootState();
}
}
/// <inheritdoc />
public async Task<WatchdogLaunchResult> Restart(bool graceful, CancellationToken cancellationToken)
{
@@ -784,12 +797,10 @@ namespace Tgstation.Server.Host.Components.Watchdog
return result;
}
var toReboot = AlphaIsActive ? alphaServer : bravoServer;
var other = AlphaIsActive ? bravoServer : alphaServer;
if (toReboot != null)
{
if (!await toReboot.SetRebootState(Components.Watchdog.RebootState.Restart, cancellationToken).ConfigureAwait(false))
logger.LogWarning("Unable to send reboot state change event!");
}
return null;
}