diff --git a/Directory.Packages.props b/Directory.Packages.props index 180e9a8..a545b84 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,14 +3,15 @@ true + - - - + + + diff --git a/MobileConfiguration/MobileConfiguration.csproj b/MobileConfiguration/MobileConfiguration.csproj index f8c7fa9..76b527c 100644 --- a/MobileConfiguration/MobileConfiguration.csproj +++ b/MobileConfiguration/MobileConfiguration.csproj @@ -11,6 +11,7 @@ + diff --git a/MobileConfiguration/Program.cs b/MobileConfiguration/Program.cs index 7449018..20347f0 100644 --- a/MobileConfiguration/Program.cs +++ b/MobileConfiguration/Program.cs @@ -14,6 +14,8 @@ using System.ComponentModel; using System.Reflection; using System.Text.Json; +using HealthChecks.UI.Client; +using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Shared.Monitoring; using ILogger = Microsoft.Extensions.Logging.ILogger; using LogLevel = Microsoft.Extensions.Logging.LogLevel; @@ -139,6 +141,7 @@ builder.Services.ConfigureHttpJsonOptions(options => { JsonSerializerConfiguration.ConfigureMinimalApi(options.SerializerOptions); }); +builder.Services.AddHealthChecks(); builder.Services.AddUptimeKuma(); var app = builder.Build(); @@ -166,6 +169,19 @@ app.MapPost("/api/TransactionMobileLogging", MobileConfiguration.Handlers.TransactionMobileLoggingHandler.PostLogging); +app.MapHealthChecks("health", + new HealthCheckOptions + { + Predicate = _ => true, + ResponseWriter = Shared.HealthChecks.HealthCheckMiddleware.WriteResponse + }); +app.MapHealthChecks("healthui", + new HealthCheckOptions + { + Predicate = _ => true, + ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse + }); + InitializeDatabase(app).Wait(CancellationToken.None); app.Lifetime.ApplicationStarted.Register(() =>