Skip to content

Commit 5aed2d4

Browse files
committed
chore: add debug logging to mutagen stop daemon
1 parent ee4ad9a commit 5aed2d4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

App/Services/MutagenController.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ private void StartDaemonProcess()
575575
/// </summary>
576576
private async Task StopDaemon(CancellationToken ct)
577577
{
578+
_logger.LogDebug("stopping mutagen daemon");
578579
var process = _daemonProcess;
579580
var client = _mutagenClient;
580581
var writer = _logWriter;
@@ -587,28 +588,34 @@ private async Task StopDaemon(CancellationToken ct)
587588
if (client == null)
588589
{
589590
if (process == null) return;
591+
_logger.LogDebug("no client; killing daemon process");
590592
process.Kill(true);
591593
}
592594
else
593595
{
594596
try
595597
{
598+
_logger.LogDebug("sending DaemonTerminateRequest");
596599
await client.Daemon.TerminateAsync(new DaemonTerminateRequest(), cancellationToken: ct);
597600
}
598-
catch
601+
catch (Exception e)
599602
{
603+
_logger.LogError(e, "failed to gracefully terminate agent");
600604
if (process == null) return;
605+
_logger.LogDebug("killing daemon process after failed graceful termination");
601606
process.Kill(true);
602607
}
603608
}
604609

605610
if (process == null) return;
606611
var cts = CancellationTokenSource.CreateLinkedTokenSource(ct);
607612
cts.CancelAfter(TimeSpan.FromSeconds(5));
613+
_logger.LogDebug("waiting for process to exit");
608614
await process.WaitForExitAsync(cts.Token);
609615
}
610616
finally
611617
{
618+
_logger.LogDebug("cleaning up daemon process objects");
612619
client?.Dispose();
613620
process?.Dispose();
614621
writer?.Dispose();

0 commit comments

Comments
 (0)