From d243666cc275f41b0e6d3301b8d1a92fb71557f8 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Sun, 15 Feb 2026 11:48:02 +0000 Subject: [PATCH] fix: Support valkey-cli in cache_health_check for Valkey-only setups - Try valkey-cli first (preferred for Valkey installations) - Fall back to redis-cli (for Redis installations) - Fall back to TCP connection test (works for both) This fixes environments that only have Valkey installed without Redis symlinks or redis-cli. Co-Authored-By: Claude Sonnet 4.5 --- src/core/bootstrap/bootstrap_utils.rs | 45 +++++++++++++++++---------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/core/bootstrap/bootstrap_utils.rs b/src/core/bootstrap/bootstrap_utils.rs index 8d89af4e4..8514bf8ec 100644 --- a/src/core/bootstrap/bootstrap_utils.rs +++ b/src/core/bootstrap/bootstrap_utils.rs @@ -93,31 +93,42 @@ pub fn vault_health_check() -> bool { /// Check if Valkey/Redis cache is healthy pub fn cache_health_check() -> bool { - // Try to PING the cache server - match Command::new("redis-cli") + // Try valkey-cli first (preferred for Valkey installations) + if let Ok(output) = Command::new("valkey-cli") .args(["-h", "127.0.0.1", "-p", "6379", "ping"]) .output() { - Ok(output) => { - if output.status.success() { - let response = String::from_utf8_lossy(&output.stdout); - response.trim().to_uppercase() == "PONG" - } else { - false + if output.status.success() { + let response = String::from_utf8_lossy(&output.stdout); + if response.trim().to_uppercase() == "PONG" { + return true; } } - Err(_) => { - // If redis-cli is not available, try TCP connection - match Command::new("sh") - .arg("-c") - .arg("timeout 1 bash -c '/dev/null") - .output() - { - Ok(output) => output.status.success(), - Err(_) => false, + } + + // Try redis-cli as fallback (for Redis installations) + if let Ok(output) = Command::new("redis-cli") + .args(["-h", "127.0.0.1", "-p", "6379", "ping"]) + .output() + { + if output.status.success() { + let response = String::from_utf8_lossy(&output.stdout); + if response.trim().to_uppercase() == "PONG" { + return true; } } } + + // If CLI tools are not available, try TCP connection test + // This works for both Valkey and Redis + match Command::new("sh") + .arg("-c") + .arg("timeout 1 bash -c '/dev/null") + .output() + { + Ok(output) => output.status.success(), + Err(_) => false, + } } /// Get current user safely