Skip to content

Commit

Permalink
Add health probe only when web service is running
Browse files Browse the repository at this point in the history
  • Loading branch information
dluc committed Jul 27, 2024
1 parent d2c6b10 commit fb19ffa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions service/Service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ public static void Main(string[] args)
// Add HTTP endpoints using minimal API (https://learn.microsoft.com/aspnet/core/fundamentals/minimal-apis)
app.AddKernelMemoryEndpoints("/", authFilter);

// Health probe
app.MapGet("/health", () => Results.Ok("Service is running."))
.Produces<string>(StatusCodes.Status200OK)
.Produces<ProblemDetails>(StatusCodes.Status401Unauthorized)
.Produces<ProblemDetails>(StatusCodes.Status403Forbidden);

if (config.ServiceAuthorization.Enabled && config.ServiceAuthorization.AccessKey1 == config.ServiceAuthorization.AccessKey2)
{
app.Logger.LogError("KM Web Service: Access keys 1 and 2 have the same value. Keys should be different to allow rotation.");
Expand Down Expand Up @@ -166,12 +172,6 @@ public static void Main(string[] args)
Console.WriteLine("* Log level : " + app.Logger.GetLogLevelName());
Console.WriteLine("***************************************************************************************************************************");

// health probe
app.MapGet("/health", () => Results.Ok("Service is running."))
.Produces<string>(StatusCodes.Status200OK)
.Produces<ProblemDetails>(StatusCodes.Status401Unauthorized)
.Produces<ProblemDetails>(StatusCodes.Status403Forbidden);

app.Logger.LogInformation(
"Starting Kernel Memory service, .NET Env: {0}, Log Level: {1}, Web service: {2}, Auth: {3}, Pipeline handlers: {4}",
env,
Expand Down

0 comments on commit fb19ffa

Please sign in to comment.