Files
ersatztv/ErsatzTV/Services/RunOnce/RunHealthChecksService.cs
T
Jason DoveandGitHub 921a108684 ui updates (#2109)
* split settings into multiple pages

* show health check badge in nav menu

* undo transcoding test changes
2025-07-04 18:20:22 +00:00

36 lines
1.0 KiB
C#

using ErsatzTV.Core;
using ErsatzTV.Core.Health;
namespace ErsatzTV.Services.RunOnce;
public class RunHealthChecksService(IServiceScopeFactory serviceScopeFactory, SystemStartup systemStartup)
: BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
await Task.Yield();
await systemStartup.WaitForDatabase(stoppingToken);
if (stoppingToken.IsCancellationRequested)
{
return;
}
await systemStartup.WaitForDatabaseCleaned(stoppingToken);
if (stoppingToken.IsCancellationRequested)
{
return;
}
await systemStartup.WaitForSearchIndex(stoppingToken);
if (stoppingToken.IsCancellationRequested)
{
return;
}
using IServiceScope scope = serviceScopeFactory.CreateScope();
IHealthCheckService healthCheckService = scope.ServiceProvider.GetRequiredService<IHealthCheckService>();
await healthCheckService.PerformHealthChecks(stoppingToken);
}
}