Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update StatusHostedService.cs (#512)
Leendert de Borsted053422bafa
diff --git a/src/Utilities/AliasVault.WorkerStatus/ServiceExtensions/StatusHostedService.cs b/src/Utilities/AliasVault.WorkerStatus/ServiceExtensions/StatusHostedService.csindex 130c4b335..093710549 100644--- a/src/Utilities/AliasVault.WorkerStatus/ServiceExtensions/StatusHostedService.cs+++ b/src/Utilities/AliasVault.WorkerStatus/ServiceExtensions/StatusHostedService.cs@@ -53,13 +53,28 @@ public class StatusHostedService<T>(ILogger<StatusHostedService<T>> logger, Globwhile (!stoppingToken.IsCancellationRequested){- // Start the inner while loop with the second cancellationToken.- await ExecuteInnerAsync(stoppingToken);-- if (!stoppingToken.IsCancellationRequested)+ try+ {+ // Start the inner while loop with the second cancellationToken.+ await ExecuteInnerAsync(stoppingToken);+ }+ catch (OperationCanceledException ex){- // If the parent service was not stopped, wait for a second before attempting to restart the worker.- await Task.Delay(1000, stoppingToken);+ // Expected so we only log information.+ logger.LogInformation(ex, "StatusHostedService<{ServiceType}> is stopping due to a cancellation request.", typeof(T).Name);+ break;+ }+ catch (Exception ex)+ {+ logger.LogError(ex, "An error occurred in StatusHostedService<{ServiceType}>", typeof(T).Name);+ }+ finally+ {+ if (!stoppingToken.IsCancellationRequested)+ {+ // If the parent service was not stopped, wait for a second before attempting to restart the worker.+ await Task.Delay(1000, stoppingToken);+ }}}}@@ -127,7 +142,7 @@ public class StatusHostedService<T>(ILogger<StatusHostedService<T>> logger, Glob}// Wait for a second before checking the status again.- await Task.Delay(1000, workerCancellationTokenSource.Token);+ await Task.Delay(1000, cancellationToken);}// If we get here, cancel the worker task if it is still running.