From e3fc671a4d865cabb70e86c167e1685516b10d08 Mon Sep 17 00:00:00 2001 From: Miha Zupan Date: Thu, 23 May 2024 07:30:31 +0200 Subject: [PATCH] More logging --- Runner/JobBase.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Runner/JobBase.cs b/Runner/JobBase.cs index 32a92e9..a5d58d6 100644 --- a/Runner/JobBase.cs +++ b/Runner/JobBase.cs @@ -189,16 +189,27 @@ private async Task ReadChannelAsync() { try { + TimeSpan lastElapsed = TimeSpan.Zero; + while (!Volatile.Read(ref completed)) { await Task.Delay(100, JobTimeout); + TimeSpan elapsed; lock (_lastLogEntry) { - if (_lastLogEntry.Elapsed.TotalSeconds < 2 * 60) - { - continue; - } + elapsed = _lastLogEntry.Elapsed; + } + + if (elapsed.TotalSeconds > 30 && elapsed > lastElapsed + TimeSpan.FromSeconds(30)) + { + Console.WriteLine($"Idle for {elapsed.TotalSeconds} seconds"); + lastElapsed = elapsed; + } + + if (elapsed.TotalSeconds < 2 * 60) + { + continue; } await LogAsync("Heartbeat - I'm still here");