Make WatchdogLaunch event finish before DD starts

This commit is contained in:
Jordan Brown
2020-09-27 23:51:46 -04:00
parent a8266d0454
commit 843c3f660e
2 changed files with 8 additions and 10 deletions
@@ -192,6 +192,8 @@ namespace Tgstation.Server.Host.Components.Watchdog
Logger.LogTrace("Initializing controller with CompileJob {0}...", dmbToUse.CompileJob.Id);
await BeforeApplyDmb(dmbToUse.CompileJob, cancellationToken).ConfigureAwait(false);
dmbToUse = await PrepServerForLaunch(dmbToUse, cancellationToken).ConfigureAwait(false);
await chatTask.ConfigureAwait(false);
serverLaunchTask = SessionControllerFactory.LaunchNew(
dmbToUse,
null,
@@ -200,7 +202,10 @@ namespace Tgstation.Server.Host.Components.Watchdog
cancellationToken);
}
else
{
await chatTask.ConfigureAwait(false);
serverLaunchTask = SessionControllerFactory.Reattach(reattachInfo, cancellationToken);
}
// retrieve the session controller
Server = await serverLaunchTask.ConfigureAwait(false);
@@ -209,7 +214,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
if (Server == null)
{
await ReattachFailure(
chatTask,
cancellationToken)
.ConfigureAwait(false);
return;
@@ -474,10 +474,9 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// <summary>
/// Call from <see cref="InitControllers(Task, ReattachInformation, CancellationToken)"/> when a reattach operation fails to attempt a fresh start.
/// </summary>
/// <param name="chatTask">A, possibly active, <see cref="Task"/> for an outgoing chat message.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
/// <returns>A <see cref="Task"/> representing the running operation.</returns>
protected async Task ReattachFailure(Task chatTask, CancellationToken cancellationToken)
protected async Task ReattachFailure(CancellationToken cancellationToken)
{
// we lost the server, just restart entirely
// DCT: Operation must always run
@@ -485,13 +484,8 @@ namespace Tgstation.Server.Host.Components.Watchdog
const string FailReattachMessage = "Unable to properly reattach to server! Restarting watchdog...";
Logger.LogWarning(FailReattachMessage);
async Task ChainChatTask()
{
await chatTask.ConfigureAwait(false);
await Chat.SendWatchdogMessage(FailReattachMessage, cancellationToken).ConfigureAwait(false);
}
await InitControllers(ChainChatTask(), null, cancellationToken).ConfigureAwait(false);
var chatTask = Chat.SendWatchdogMessage(FailReattachMessage, cancellationToken);
await InitControllers(chatTask, null, cancellationToken).ConfigureAwait(false);
}
/// <summary>