Fix API deploy healthcheck by starting Kestrel before migrate/seed.
Compose was marking the API unhealthy because bootstrap blocked app.Run(), so /health/live never answered within the HEALTHCHECK window.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
|
||||
/// <summary>
|
||||
/// Tracks whether one-shot startup work (migrate / seed / MinIO bucket) has finished.
|
||||
/// Tagged on /health/ready and /health/startup so probes stay unhealthy until bootstrap completes.
|
||||
/// </summary>
|
||||
public sealed class StartupHealthCheck : IHealthCheck
|
||||
{
|
||||
private volatile bool _completed;
|
||||
|
||||
public bool StartupCompleted
|
||||
{
|
||||
get => _completed;
|
||||
set => _completed = value;
|
||||
}
|
||||
|
||||
public Task<HealthCheckResult> CheckHealthAsync(
|
||||
HealthCheckContext context, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return Task.FromResult(
|
||||
_completed
|
||||
? HealthCheckResult.Healthy("Startup completed.")
|
||||
: HealthCheckResult.Unhealthy("Startup still running."));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user