From a1cbb9fb1d40b2f3c51d6f094ab27875bf98b182 Mon Sep 17 00:00:00 2001 From: iven Date: Wed, 6 May 2026 10:21:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(server):=20readiness=5Fcheck=20=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E5=86=85=E9=83=A8=E9=94=99=E8=AF=AF=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/erp-server/src/handlers/health.rs | 39 +++++++++++++++--------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/crates/erp-server/src/handlers/health.rs b/crates/erp-server/src/handlers/health.rs index a223e0c..018102a 100644 --- a/crates/erp-server/src/handlers/health.rs +++ b/crates/erp-server/src/handlers/health.rs @@ -91,11 +91,14 @@ async fn check_database(db: &sea_orm::DatabaseConnection) -> ComponentStatus { latency_ms: Some(start.elapsed().as_millis() as u64), error: None, }, - Err(e) => ComponentStatus { - status: "error".to_string(), - latency_ms: Some(start.elapsed().as_millis() as u64), - error: Some(e.to_string()), - }, + Err(e) => { + tracing::error!(error = %e, "Database health check failed"); + ComponentStatus { + status: "error".to_string(), + latency_ms: Some(start.elapsed().as_millis() as u64), + error: Some("connection failed".to_string()), + } + } } } @@ -112,18 +115,24 @@ async fn check_redis(client: &redis::Client) -> ComponentStatus { latency_ms: Some(start.elapsed().as_millis() as u64), error: None, }, - Err(e) => ComponentStatus { - status: "error".to_string(), - latency_ms: Some(start.elapsed().as_millis() as u64), - error: Some(e.to_string()), - }, + Err(e) => { + tracing::error!(error = %e, "Redis PING failed"); + ComponentStatus { + status: "error".to_string(), + latency_ms: Some(start.elapsed().as_millis() as u64), + error: Some("connection failed".to_string()), + } + } + } + } + Err(e) => { + tracing::error!(error = %e, "Redis connection failed"); + ComponentStatus { + status: "error".to_string(), + latency_ms: Some(start.elapsed().as_millis() as u64), + error: Some("connection failed".to_string()), } } - Err(e) => ComponentStatus { - status: "error".to_string(), - latency_ms: Some(start.elapsed().as_millis() as u64), - error: Some(e.to_string()), - }, } }