Se añade servicio de HealtCheck de SqlServer
All checks were successful
Optimized Build and Deploy / remote-build-and-deploy (push) Successful in 7m19s
All checks were successful
Optimized Build and Deploy / remote-build-and-deploy (push) Successful in 7m19s
Se pretende utilizar mediante Kuma
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="9.0.0" />
|
||||
<PackageReference Include="Dapper" Version="2.1.66" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.3" />
|
||||
|
||||
@@ -16,6 +16,7 @@ using Microsoft.OpenApi.Models;
|
||||
using GestionIntegral.Api.Data.Repositories.Reportes;
|
||||
using GestionIntegral.Api.Services.Reportes;
|
||||
using GestionIntegral.Api.Services.Pdf;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -96,6 +97,18 @@ builder.Services.AddScoped<IReportesService, ReportesService>();
|
||||
// QuestPDF
|
||||
builder.Services.AddScoped<IQuestPdfGenerator, QuestPdfGenerator>();
|
||||
|
||||
// --- SERVICIO DE HEALTH CHECKS ---
|
||||
// Añadimos una comprobación específica para SQL Server.
|
||||
// El sistema usará la cadena de conexión configurada en appsettings.json o variables de entorno.
|
||||
builder.Services.AddHealthChecks()
|
||||
.AddSqlServer(
|
||||
connectionString: builder.Configuration.GetConnectionString("DefaultConnection") ?? "",
|
||||
healthQuery: "SELECT 1;",
|
||||
name: "sql-server",
|
||||
failureStatus: HealthStatus.Unhealthy,
|
||||
tags: new string[] { "database" }
|
||||
);
|
||||
|
||||
// --- Configuración de Autenticación JWT ---
|
||||
var jwtSettings = builder.Configuration.GetSection("Jwt");
|
||||
|
||||
@@ -226,6 +239,10 @@ app.UseCors(MyAllowSpecificOrigins);
|
||||
app.UseAuthentication(); // Debe ir ANTES de UseAuthorization
|
||||
app.UseAuthorization();
|
||||
|
||||
// Mapeamos la ruta "/health". Cuando se acceda a ella, se ejecutarán todas las comprobaciones registradas.
|
||||
// Esto va ANTES de app.MapControllers().
|
||||
app.MapHealthChecks("/health");
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
Reference in New Issue
Block a user