move gauge init into cleanup task

This commit is contained in:
Stanley Dimant
2025-01-14 10:17:00 +01:00
parent e633151b35
commit 355d34c730

View File

@@ -32,8 +32,6 @@ public class MainFileCleanupService : IHostedService
{ {
_logger.LogInformation("Cleanup Service started"); _logger.LogInformation("Cleanup Service started");
InitializeGauges();
_cleanupCts = new(); _cleanupCts = new();
_ = Task.Run(() => CleanUpTask(_cleanupCts.Token)).ConfigureAwait(false); _ = Task.Run(() => CleanUpTask(_cleanupCts.Token)).ConfigureAwait(false);
@@ -150,6 +148,8 @@ public class MainFileCleanupService : IHostedService
private async Task CleanUpTask(CancellationToken ct) private async Task CleanUpTask(CancellationToken ct)
{ {
InitializeGauges();
while (!ct.IsCancellationRequested) while (!ct.IsCancellationRequested)
{ {
var cleanupCheckMinutes = _configuration.GetValueOrDefault(nameof(StaticFilesServerConfiguration.CleanupCheckInMinutes), 15); var cleanupCheckMinutes = _configuration.GetValueOrDefault(nameof(StaticFilesServerConfiguration.CleanupCheckInMinutes), 15);