diff --git a/CallbackHandler.Tests/BootstrapperTests.cs b/CallbackHandler.Tests/BootstrapperTests.cs index ff29157..6ed62cc 100644 --- a/CallbackHandler.Tests/BootstrapperTests.cs +++ b/CallbackHandler.Tests/BootstrapperTests.cs @@ -64,6 +64,7 @@ private void AddTestRegistrations(ServiceRegistry services, services.AddSingleton(diagnosticSource); services.AddSingleton(hostingEnvironment); services.AddSingleton(hostingEnvironment); + services.AddSingleton(Startup.Configuration); } } } diff --git a/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs b/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs index 67c6d18..29c2e75 100644 --- a/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs +++ b/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs @@ -1,6 +1,7 @@ using KurrentDB.Client; using Microsoft.Extensions.Logging; using Microsoft.OpenApi; +using Shared.Monitoring; using Swashbuckle.AspNetCore.SwaggerGen; namespace CallbackHandler.Bootstrapper; @@ -45,6 +46,8 @@ public MiddlewareRegistry() this.AddSingleton(new RequestResponseMiddlewareLoggingConfig(middlewareLogLevel, logRequests, logResponses)); this.ConfigureHttpJsonOptions(jsonOptions => JsonSerializerConfiguration.ConfigureMinimalApi(jsonOptions.SerializerOptions)); + + this.AddUptimeKuma(); } private void AddSwaggerAction(SwaggerGenOptions c) { diff --git a/CallbackHandler/Startup.cs b/CallbackHandler/Startup.cs index 9f22476..175f0c2 100644 --- a/CallbackHandler/Startup.cs +++ b/CallbackHandler/Startup.cs @@ -18,6 +18,7 @@ namespace CallbackHandler using Shared.General; using Shared.Logger; using Shared.Middleware; + using Shared.Monitoring; using Shared.Serialisation; using System.Diagnostics.CodeAnalysis; using ILogger = Microsoft.Extensions.Logging.ILogger; @@ -67,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()) { @@ -106,6 +108,13 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF app.UseSwagger(); app.UseSwaggerUI(); + + lifetime.ApplicationStarted.Register(() => + { + host.RegisterWithUptimeKumaAsync() + .GetAwaiter() + .GetResult(); + }); } } } diff --git a/CallbackHandler/appsettings.json b/CallbackHandler/appsettings.json index 1797133..e0cfbed 100644 --- a/CallbackHandler/appsettings.json +++ b/CallbackHandler/appsettings.json @@ -1,3 +1,10 @@ { - + + "UptimeKuma": { + "Monitor": { + "Name": "Callback Handler", + "Url": "http://localhost:5010/health", + "IntervalInSeconds": 60 + } + } } diff --git a/Directory.Packages.props b/Directory.Packages.props index 6d1bfc6..c8e3470 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,10 +5,10 @@ - - - - + + + + @@ -19,20 +19,20 @@ - - - - - - + + + + + + - - + + - - + + @@ -40,8 +40,8 @@ - + - + \ No newline at end of file