This commit is contained in:
Flaminel
2025-05-16 19:16:32 +03:00
parent 3c2bb7a289
commit f2027f77a9
17 changed files with 1780 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
using Infrastructure.Health;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
@@ -11,6 +12,13 @@ public static class ApiDI
// Add API-specific services
services.AddControllers();
services.AddEndpointsApiExplorer();
// Add SignalR for real-time updates
services.AddSignalR();
// Add health status broadcaster
services.AddHostedService<HealthStatusBroadcaster>();
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
@@ -45,6 +53,9 @@ public static class ApiDI
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
// Map SignalR hubs
app.MapHub<HealthStatusHub>("/hubs/health");
return app;
}

View File

@@ -3,6 +3,7 @@ using Common.Configuration.General;
using Common.Helpers;
using Domain.Models.Arr;
using Infrastructure.Configuration;
using Infrastructure.Health;
using Infrastructure.Http;
using Infrastructure.Services;
using Infrastructure.Verticals.DownloadClient.Factory;
@@ -29,6 +30,7 @@ public static class MainDI
})
.AddServices()
.AddDownloadClientServices()
.AddHealthServices()
.AddQuartzServices(configuration)
.AddNotifications(configuration)
.AddMassTransit(config =>
@@ -121,4 +123,15 @@ public static class MainDI
.AddTransient<Infrastructure.Verticals.DownloadClient.QBittorrent.QBitService>()
.AddTransient<Infrastructure.Verticals.DownloadClient.Transmission.TransmissionService>()
.AddTransient<Infrastructure.Verticals.DownloadClient.Deluge.DelugeService>();
/// <summary>
/// Adds health check services to the service collection
/// </summary>
private static IServiceCollection AddHealthServices(this IServiceCollection services) =>
services
// Register the health check service
.AddSingleton<IHealthCheckService, HealthCheckService>()
// Register the background service for periodic health checks
.AddHostedService<HealthCheckBackgroundService>();
}