Skip to content

Commit a17c915

Browse files
committed
chore: add debug logging to mutagen stop daemon
1 parent 153ceb3 commit a17c915

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

App/Services/MutagenController.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ private void StartDaemonProcess()
578578
/// </summary>
579579
private async Task StopDaemon(CancellationToken ct)
580580
{
581+
_logger.LogDebug("stopping mutagen daemon");
581582
var process = _daemonProcess;
582583
var client = _mutagenClient;
583584
var writer = _logWriter;
@@ -590,28 +591,34 @@ private async Task StopDaemon(CancellationToken ct)
590591
if (client == null)
591592
{
592593
if (process == null) return;
594+
_logger.LogDebug("no client; killing daemon process");
593595
process.Kill(true);
594596
}
595597
else
596598
{
597599
try
598600
{
601+
_logger.LogDebug("sending DaemonTerminateRequest");
599602
await client.Daemon.TerminateAsync(new DaemonTerminateRequest(), cancellationToken: ct);
600603
}
601-
catch
604+
catch (Exception e)
602605
{
606+
_logger.LogError(e, "failed to gracefully terminate agent");
603607
if (process == null) return;
608+
_logger.LogDebug("killing daemon process after failed graceful termination");
604609
process.Kill(true);
605610
}
606611
}
607612

608613
if (process == null) return;
609614
var cts = CancellationTokenSource.CreateLinkedTokenSource(ct);
610615
cts.CancelAfter(TimeSpan.FromSeconds(5));
616+
_logger.LogDebug("waiting for process to exit");
611617
await process.WaitForExitAsync(cts.Token);
612618
}
613619
finally
614620
{
621+
_logger.LogDebug("cleaning up daemon process objects");
615622
client?.Dispose();
616623
process?.Dispose();
617624
writer?.Dispose();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy