diff --git a/Directory.Packages.props b/Directory.Packages.props
index 2827f4f..cd95444 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -3,46 +3,46 @@
true
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
-
-
-
+
+
+
@@ -50,13 +50,13 @@
-
-
+
+
-
-
+
+
-
+
\ No newline at end of file
diff --git a/MessagingService/Bootstrapper/MiddlewareRegistry.cs b/MessagingService/Bootstrapper/MiddlewareRegistry.cs
index 7ee4198..6fdde5a 100644
--- a/MessagingService/Bootstrapper/MiddlewareRegistry.cs
+++ b/MessagingService/Bootstrapper/MiddlewareRegistry.cs
@@ -3,10 +3,10 @@
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi;
using Shared.Authorisation;
+using Shared.Serialisation;
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
-using Shared.Serialisation;
namespace MessagingService.Bootstrapper
{
@@ -20,6 +20,7 @@ namespace MessagingService.Bootstrapper
using Shared.EventStore.Extensions;
using Shared.General;
using Shared.Middleware;
+ using Shared.Monitoring;
using Swashbuckle.AspNetCore.Filters;
using System;
using System.Diagnostics.CodeAnalysis;
@@ -56,6 +57,8 @@ public MiddlewareRegistry() {
this.AddSingleton(config);
this.ConfigureHttpJsonOptions(jsonOptions => JsonSerializerConfiguration.ConfigureMinimalApi(jsonOptions.SerializerOptions));
+
+ this.AddUptimeKuma();
}
private void ConfigureAuthentication() {
diff --git a/MessagingService/Startup.cs b/MessagingService/Startup.cs
index e2a9e60..cfc821d 100644
--- a/MessagingService/Startup.cs
+++ b/MessagingService/Startup.cs
@@ -7,6 +7,7 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
+using System.Threading.Tasks;
namespace MessagingService
{
@@ -26,6 +27,7 @@ namespace MessagingService
using Shared.General;
using Shared.Logger;
using Shared.Middleware;
+ using Shared.Monitoring;
using Shared.Serialisation;
using SMSMessage.DomainEvents;
using System.Diagnostics;
@@ -66,7 +68,8 @@ public void ConfigureContainer(ServiceRegistry services)
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory,
+ IHostApplicationLifetime lifetime, IHost host)
{
if (env.IsDevelopment())
{
@@ -113,7 +116,24 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF
app.UseSwaggerUI();
+ lifetime.ApplicationStarted.Register(() =>
+ {
+ _ = RegisterWithUptimeKumaAsync(host);
+ });
+
app.PreWarm();
}
+
+ private static async Task RegisterWithUptimeKumaAsync(IHost host)
+ {
+ try
+ {
+ await host.RegisterWithUptimeKumaAsync();
+ }
+ catch (Exception ex)
+ {
+ Shared.Logger.Logger.LogError("Failed to register the Messaging Service with Uptime Kuma.", ex);
+ }
+ }
}
}
diff --git a/MessagingService/appsettings.json b/MessagingService/appsettings.json
index e27b842..cb60484 100644
--- a/MessagingService/appsettings.json
+++ b/MessagingService/appsettings.json
@@ -40,7 +40,14 @@
]
}
},
- "SecurityConfiguration": {
- "ApiName": "messagingService"
+ "SecurityConfiguration": {
+ "ApiName": "messagingService"
+ },
+ "UptimeKuma": {
+ "Monitor": {
+ "Name": "Messaging Service",
+ "Url": "http://localhost:5006/health",
+ "IntervalInSeconds": 60
}
}
+}