Skip to content

Commit

Permalink
Add Liveness health check for specific host name(s) and port number(s)
Browse files Browse the repository at this point in the history
- for the endpoint /health-on-host
  • Loading branch information
sztrelcsikzoltan committed Jul 4, 2023
1 parent 8cc5d1d commit 05571eb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions InvestmentManager/InvestmentManager/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
builder.Services.AddStockIndexServiceHttpClientWithoutProfiler(stockIndexServiceUrl);
builder.Services.AddInvestmentManagerServices(stockIndexServiceUrl);

// HEALTH CHECKS

// Liveness healh check
builder.Services.AddHealthChecks();

Expand All @@ -72,8 +74,16 @@

app.UseAuthorization();

// Configure Liveness health check
app.UseEndpoints(endpoints => { endpoints.MapHealthChecks("/health"); });
app.UseEndpoints(endpoints =>
{
// CONFIGURE HEALTH CHECKS

// Liveness health check
endpoints.MapHealthChecks("/health");

// Liveness health check for specific host name(s) and port number(s)
endpoints.MapHealthChecks("/health-on-host").RequireHost(hosts: new string[] { "localhost:51500", "localhost:51501" } );
});

app.MapControllerRoute(
name: "default",
Expand Down

0 comments on commit 05571eb

Please sign in to comment.