feat: Add diagnostic logging for hosted services resolution and startup timing

This commit is contained in:
HueByte
2026-02-19 13:37:51 +01:00
parent 2a6dbb4461
commit c8e33c96ce
+9
View File
@@ -202,6 +202,15 @@ while (true)
} }
}, heartbeatCts.Token); }, heartbeatCts.Token);
// ── Enumerate hosted services (DI resolution) ────────────────────
Console.Error.WriteLine("[DIAG] Resolving IHostedService instances from DI...");
var hostedServices = app.Services.GetServices<IHostedService>().ToList();
Console.Error.WriteLine($"[DIAG] Found {hostedServices.Count} hosted services:");
foreach (var svc in hostedServices)
Console.Error.WriteLine($"[DIAG] - {svc.GetType().FullName}");
Console.Error.Flush();
// ── Start with per-service timing ─────────────────────────────────
Console.Error.WriteLine("[DIAG] Calling app.StartAsync()..."); Console.Error.WriteLine("[DIAG] Calling app.StartAsync()...");
await app.StartAsync(); await app.StartAsync();
Console.Error.WriteLine("[DIAG] app.StartAsync() completed — server is running."); Console.Error.WriteLine("[DIAG] app.StartAsync() completed — server is running.");