🐛 Brings health check back to live

This commit is contained in:
2025-10-07 00:34:00 +08:00
parent 282a1dbddc
commit e634968e00
2 changed files with 23 additions and 12 deletions

View File

@@ -100,6 +100,22 @@ var routes = specialRoutes.Concat(apiRoutes).Concat(swaggerRoutes).ToArray();
var clusters = serviceNames.Select(serviceName => new ClusterConfig var clusters = serviceNames.Select(serviceName => new ClusterConfig
{ {
ClusterId = serviceName, ClusterId = serviceName,
HealthCheck = new()
{
Active = new()
{
Enabled = true,
Interval = TimeSpan.FromSeconds(10),
Timeout = TimeSpan.FromSeconds(5),
Policy = "ActiveHealthy",
Path = "/health"
},
Passive = new()
{
Enabled = true,
Policy = "PassiveHealthy"
}
},
Destinations = new Dictionary<string, DestinationConfig> Destinations = new Dictionary<string, DestinationConfig>
{ {
{ "destination1", new DestinationConfig { Address = $"http://{serviceName}" } } { "destination1", new DestinationConfig { Address = $"http://{serviceName}" } }

View File

@@ -117,10 +117,6 @@ public static class Extensions
} }
public static WebApplication MapDefaultEndpoints(this WebApplication app) public static WebApplication MapDefaultEndpoints(this WebApplication app)
{
// Adding health checks endpoints to applications in non-development environments has security implications.
// See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
if (app.Environment.IsDevelopment())
{ {
// All health checks must pass for app to be considered ready to accept traffic after starting // All health checks must pass for app to be considered ready to accept traffic after starting
app.MapHealthChecks(HealthEndpointPath); app.MapHealthChecks(HealthEndpointPath);
@@ -130,7 +126,6 @@ public static class Extensions
{ {
Predicate = r => r.Tags.Contains("live") Predicate = r => r.Tags.Contains("live")
}); });
}
return app; return app;
} }