Merge pull request #839 from tgstation/838-FixReattachFail

Do not releaseServers if StopAsync fails
This commit is contained in:
Jordan Brown
2018-12-23 15:27:20 -05:00
committed by GitHub
@@ -996,20 +996,28 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// <inheritdoc />
public async Task StopAsync(CancellationToken cancellationToken)
{
if (releaseServers && Running)
try
{
await StopMonitor().ConfigureAwait(false);
var reattachInformation = new WatchdogReattachInformation
if (releaseServers && Running)
{
AlphaIsActive = AlphaIsActive
};
reattachInformation.Alpha = alphaServer?.Release();
reattachInformation.Bravo = bravoServer?.Release();
await reattachInfoHandler.Save(reattachInformation, cancellationToken).ConfigureAwait(false);
}
await StopMonitor().ConfigureAwait(false);
await Terminate(false, cancellationToken).ConfigureAwait(false);
var reattachInformation = new WatchdogReattachInformation
{
AlphaIsActive = AlphaIsActive
};
reattachInformation.Alpha = alphaServer?.Release();
reattachInformation.Bravo = bravoServer?.Release();
await reattachInfoHandler.Save(reattachInformation, cancellationToken).ConfigureAwait(false);
}
await Terminate(false, cancellationToken).ConfigureAwait(false);
}
catch
{
releaseServers = false;
throw;
}
}
/// <inheritdoc />