fix: ajuste no health check
All checks were successful
BCards Deployment Pipeline / Run Tests (push) Successful in 2s
BCards Deployment Pipeline / PR Validation (push) Has been skipped
BCards Deployment Pipeline / Build and Push Image (push) Successful in 15m20s
BCards Deployment Pipeline / Deploy to Production (ARM - OCI) (push) Successful in 1m22s
BCards Deployment Pipeline / Deploy to Staging (x86 - Local) (push) Has been skipped
BCards Deployment Pipeline / Cleanup Old Resources (push) Has been skipped
BCards Deployment Pipeline / Deployment Summary (push) Successful in 1s

This commit is contained in:
Ricardo Carneiro 2025-09-07 01:07:44 -03:00
parent a434ff56eb
commit 5abb4b52c5

View File

@ -9,7 +9,7 @@ namespace BCards.Web.HealthChecks;
/// Health check para serviços CRÍTICOS - falha = ALERTA VERMELHO 🔴 /// Health check para serviços CRÍTICOS - falha = ALERTA VERMELHO 🔴
/// - MongoDB (páginas não funcionam) /// - MongoDB (páginas não funcionam)
/// - Stripe (pagamentos não funcionam) /// - Stripe (pagamentos não funcionam)
/// - Live Pages (usuários não conseguem acessar páginas) /// - Website (implícito - se este check executa, o site funciona)
/// </summary> /// </summary>
public class CriticalServicesHealthCheck : IHealthCheck public class CriticalServicesHealthCheck : IHealthCheck
{ {
@ -86,38 +86,9 @@ public class CriticalServicesHealthCheck : IHealthCheck
await Task.Delay(1000, cancellationToken); await Task.Delay(1000, cancellationToken);
} }
// 3. Self Health Check - verificar se o próprio site responde // 3. Self Health Check removido - se este código está executando, o website já está funcionando
try
{
var baseUrl = Environment.GetEnvironmentVariable("BASE_URL") ?? "https://bcards.site";
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
using var response = await _httpClient.GetAsync($"{baseUrl}/health", cts.Token);
if (response.IsSuccessStatusCode)
{
results["website"] = new { status = "healthy", service = "website" }; results["website"] = new { status = "healthy", service = "website" };
_logger.LogDebug("✅ Website principal está respondendo"); _logger.LogDebug("✅ Website está operacional (health check executando)");
}
else
{
allCritical = false;
criticalFailures.Add("Website");
results["website"] = new { status = "unhealthy", status_code = (int)response.StatusCode, service = "website" };
_logger.LogError("🔴 CRÍTICO: Website principal não responde! Status: {StatusCode}",
(int)response.StatusCode);
await Task.Delay(2000, cancellationToken); // Delay maior para site down
}
}
catch (Exception ex)
{
allCritical = false;
criticalFailures.Add("Website");
results["website"] = new { status = "unhealthy", error = ex.Message, service = "website" };
_logger.LogError(ex, "🔴 CRÍTICO: Website principal inacessível!");
await Task.Delay(2000, cancellationToken);
}
var data = new Dictionary<string, object> var data = new Dictionary<string, object>
{ {