From ba7f1ba5ebc77cbc6d16dbeec7c680b4de29df34 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Wed, 1 Apr 2026 18:11:26 -0300 Subject: [PATCH] fix: Valkey health check uses absolute path to valkey-cli - Use BOTSERVER_STACK_PATH/bin/cache/bin/valkey-cli instead of relying on PATH - Remove bash /dev/tcp fallback (unreliable in restricted environments) - Falls back to redis-cli and nc if valkey-cli unavailable --- src/core/bootstrap/bootstrap_utils.rs | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/core/bootstrap/bootstrap_utils.rs b/src/core/bootstrap/bootstrap_utils.rs index 1f582d1d..3fbaea0f 100644 --- a/src/core/bootstrap/bootstrap_utils.rs +++ b/src/core/bootstrap/bootstrap_utils.rs @@ -119,7 +119,11 @@ pub fn vault_health_check() -> bool { /// Check if Valkey/Redis cache is healthy pub fn cache_health_check() -> bool { - if let Ok(output) = SafeCommand::new("valkey-cli") + let stack_path = + std::env::var("BOTSERVER_STACK_PATH").unwrap_or_else(|_| "./botserver-stack".to_string()); + let valkey_cli = format!("{}/bin/cache/bin/valkey-cli", stack_path); + + if let Ok(output) = SafeCommand::new(&valkey_cli) .and_then(|c| c.args(&["-h", "127.0.0.1", "-p", "6379", "ping"])) .and_then(|c| c.execute()) { @@ -148,24 +152,7 @@ pub fn cache_health_check() -> bool { .and_then(|c| c.execute()) { Ok(output) => output.status.success(), - Err(_) => { - match SafeCommand::new("bash") - .and_then(|c| c.arg("-c")) - .and_then(|c| { - c.arg( - "exec 3<>/dev/tcp/127.0.0.1/6379 2>/dev/null && \ - echo -e 'PING\r\n' >&3 && \ - read -t 1 response <&3 && \ - [[ \"$response\" == *PONG* ]] && \ - exec 3>&-", - ) - }) - .and_then(|c| c.execute()) - { - Ok(output) => output.status.success(), - Err(_) => false, - } - } + Err(_) => false, } }