Host infrastructure (WP-11–17): - StartupValidator with 19 validation rules - /health/ready endpoint with DB + Akka health checks - Akka.NET bootstrap via AkkaHostedService (HOCON config, cluster, remoting, SBR) - Serilog with SiteId/NodeHostname/NodeRole enrichment - DeadLetterMonitorActor with count tracking - CoordinatedShutdown wiring (no Environment.Exit) - Windows Service support (UseWindowsService) Central UI (WP-18–21): - Blazor Server shell with Bootstrap 5, role-aware NavMenu - Login/logout flow (LDAP auth → JWT → HTTP-only cookie) - CookieAuthenticationStateProvider with idle timeout - LDAP group mapping CRUD page (Admin role) - Route guards with Authorize attributes per role - SignalR reconnection overlay for failover Integration tests (WP-22): - Startup validation, auth flow, audit transactions, readiness gating 186 tests pass (1 skipped: LDAP integration), zero warnings.
35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
|
using ScadaLink.ConfigurationDatabase;
|
|
|
|
namespace ScadaLink.Host.Health;
|
|
|
|
/// <summary>
|
|
/// Health check that verifies database connectivity for Central nodes.
|
|
/// </summary>
|
|
public class DatabaseHealthCheck : IHealthCheck
|
|
{
|
|
private readonly ScadaLinkDbContext _dbContext;
|
|
|
|
public DatabaseHealthCheck(ScadaLinkDbContext dbContext)
|
|
{
|
|
_dbContext = dbContext;
|
|
}
|
|
|
|
public async Task<HealthCheckResult> CheckHealthAsync(
|
|
HealthCheckContext context,
|
|
CancellationToken cancellationToken = default)
|
|
{
|
|
try
|
|
{
|
|
var canConnect = await _dbContext.Database.CanConnectAsync(cancellationToken);
|
|
return canConnect
|
|
? HealthCheckResult.Healthy("Database connection is available.")
|
|
: HealthCheckResult.Unhealthy("Database connection failed.");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return HealthCheckResult.Unhealthy("Database connection failed.", ex);
|
|
}
|
|
}
|
|
}
|