Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="AspNetCore.HealthChecks.SqlServer" Version="9.0.0" />
<PackageVersion Include="AspNetCore.HealthChecks.UI.Client" Version="9.0.0" />
<PackageVersion Include="HealthMonitoring.Client" Version="2026.9.2.21" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.12" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="10.0.12" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.12" />
Expand Down
4 changes: 3 additions & 1 deletion MobileConfiguration/MobileConfiguration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@


<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" />
<PackageReference Include="HealthMonitoring.Client" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
Expand Down
32 changes: 19 additions & 13 deletions MobileConfiguration/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using HealthChecks.UI.Client;
using HealthMonitoring.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using MobileConfiguration.Database;
using MobileConfiguration.Repository;
using NLog;
Expand All @@ -10,13 +14,12 @@
using Shared.Logger;
using Shared.Logger.TennantContext;
using Shared.Middleware;
using Shared.Monitoring;
using Shared.Serialisation;
using System.ComponentModel;
using System.Reflection;
using System.Text.Json;
using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Shared.Monitoring;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using ILogger = Microsoft.Extensions.Logging.ILogger;
using LogLevel = Microsoft.Extensions.Logging.LogLevel;

Expand All @@ -28,7 +31,11 @@
.AddJsonFile("/home/txnproc/config/appsettings.json", true, true)
.AddJsonFile($"/home/txnproc/config/appsettings.{builder.Environment.EnvironmentName}.json", optional: true)
.AddJsonFile($"/home/txnproc/config/appsettings.local.json", optional: true)
.AddEnvironmentVariables().Build();
.AddEnvironmentVariables()
.AddInMemoryCollection(new Dictionary<string, string?>
{
["HealthMonitoring:Service:Version"] = Assembly.GetEntryAssembly()?.GetName().Version?.ToString() ?? "0.0.0.0"
}).Build();

ConfigurationReader.Initialise(configuration);

Expand Down Expand Up @@ -141,8 +148,14 @@
builder.Services.ConfigureHttpJsonOptions(options => {
JsonSerializerConfiguration.ConfigureMinimalApi(options.SerializerOptions);
});
builder.Services.AddHealthChecks();
builder.Services.AddUptimeKuma();
builder.Services.AddHealthChecks().AddSqlServer(
connectionString: ConfigurationReader.GetConnectionString("ConfigurationDatabase"),
healthQuery: "SELECT 1;",
name: "Config Database Server",
failureStatus: HealthStatus.Degraded,
tags: new[] { "db", "sql", "sqlserver" });

builder.Services.AddHealthMonitoringRegistration(configuration);

var app = builder.Build();

Expand Down Expand Up @@ -184,13 +197,6 @@

InitializeDatabase(app).Wait(CancellationToken.None);

app.Lifetime.ApplicationStarted.Register(() =>
{
app.RegisterWithUptimeKumaAsync()
.GetAwaiter()
.GetResult();
});

app.Run();


Expand Down
17 changes: 12 additions & 5 deletions MobileConfiguration/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@
"ConnectionStrings": {
"ConfigurationDatabase": "server=192.168.1.163;user id=sa;password=Sc0tland;database=ConfigurationHost;Encrypt=false"
},
"UptimeKuma": {
"Monitor": {
"HealthMonitoring": {
"Service": {
"ServiceId": "mobile-configuration",
"Name": "Mobile Configuration",
"Url": "http://localhost:9200/health",
"IntervalInSeconds": 60
}
"Description": "Mobile Configuration",
"HealthUrl": "http://localhost:9200/healthui"
},
"Dependencies": [
{
"DependencyName": "Config Database Server",
"TargetServiceId": "sql-server"
}
]
}
}
Loading