fix: Support valkey-cli in cache_health_check for Valkey-only setups
All checks were successful
BotServer CI / build (push) Successful in 8m19s
All checks were successful
BotServer CI / build (push) Successful in 8m19s
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
ba70bd97bc
commit
d243666cc2
1 changed files with 28 additions and 17 deletions
|
|
@ -93,21 +93,34 @@ pub fn vault_health_check() -> bool {
|
||||||
|
|
||||||
/// Check if Valkey/Redis cache is healthy
|
/// Check if Valkey/Redis cache is healthy
|
||||||
pub fn cache_health_check() -> bool {
|
pub fn cache_health_check() -> bool {
|
||||||
// Try to PING the cache server
|
// Try valkey-cli first (preferred for Valkey installations)
|
||||||
match Command::new("redis-cli")
|
if let Ok(output) = Command::new("valkey-cli")
|
||||||
.args(["-h", "127.0.0.1", "-p", "6379", "ping"])
|
.args(["-h", "127.0.0.1", "-p", "6379", "ping"])
|
||||||
.output()
|
.output()
|
||||||
{
|
{
|
||||||
Ok(output) => {
|
|
||||||
if output.status.success() {
|
if output.status.success() {
|
||||||
let response = String::from_utf8_lossy(&output.stdout);
|
let response = String::from_utf8_lossy(&output.stdout);
|
||||||
response.trim().to_uppercase() == "PONG"
|
if response.trim().to_uppercase() == "PONG" {
|
||||||
} else {
|
return true;
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_) => {
|
}
|
||||||
// If redis-cli is not available, try TCP connection
|
|
||||||
|
// 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")
|
match Command::new("sh")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg("timeout 1 bash -c '</dev/tcp/127.0.0.1/6379' 2>/dev/null")
|
.arg("timeout 1 bash -c '</dev/tcp/127.0.0.1/6379' 2>/dev/null")
|
||||||
|
|
@ -117,8 +130,6 @@ pub fn cache_health_check() -> bool {
|
||||||
Err(_) => false,
|
Err(_) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get current user safely
|
/// Get current user safely
|
||||||
pub fn safe_fuser() -> String {
|
pub fn safe_fuser() -> String {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue