mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-05-16 12:29:01 -04:00
Add StatusWorker sanity checks to prevent soft-stopped background service behavior
This commit is contained in:
@@ -223,6 +223,14 @@
|
||||
service.CurrentStatus = entry.CurrentStatus;
|
||||
service.DesiredStatus = entry.DesiredStatus;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No record exists - service hasn't started yet or database issue.
|
||||
// Show as offline/stopped state so the button displays red (not transparent).
|
||||
service.IsHeartBeatValid = false;
|
||||
service.CurrentStatus = "Stopped";
|
||||
service.DesiredStatus = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
@@ -26,6 +26,17 @@ public class StatusWorker(ILogger<StatusWorker> logger, Func<IWorkerStatusDbCont
|
||||
/// <returns>Task.</returns>
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var initDbContext = createDbContext();
|
||||
_dbContext = initDbContext;
|
||||
await GetOrCreateInitialStatusRecordAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError(e, "Failed to initialize service status record for {ServiceName}", globalServiceStatus.ServiceName);
|
||||
}
|
||||
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
using var dbContext = createDbContext();
|
||||
|
||||
Reference in New Issue
Block a user