🐛 Brings health check back to live
This commit is contained in:
@@ -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}" } }
|
||||||
|
@@ -118,19 +118,14 @@ 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.
|
// All health checks must pass for app to be considered ready to accept traffic after starting
|
||||||
// See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
|
app.MapHealthChecks(HealthEndpointPath);
|
||||||
if (app.Environment.IsDevelopment())
|
|
||||||
{
|
|
||||||
// All health checks must pass for app to be considered ready to accept traffic after starting
|
|
||||||
app.MapHealthChecks(HealthEndpointPath);
|
|
||||||
|
|
||||||
// Only health checks tagged with the "live" tag must pass for app to be considered alive
|
// Only health checks tagged with the "live" tag must pass for app to be considered alive
|
||||||
app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions
|
app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions
|
||||||
{
|
{
|
||||||
Predicate = r => r.Tags.Contains("live")
|
Predicate = r => r.Tags.Contains("live")
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user