fix: Valkey health check uses absolute path to valkey-cli
Some checks failed
BotServer CI/CD / build (push) Has been cancelled
Some checks failed
BotServer CI/CD / build (push) Has been cancelled
- 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
This commit is contained in:
parent
68ef554132
commit
ba7f1ba5eb
1 changed files with 6 additions and 19 deletions
|
|
@ -119,7 +119,11 @@ 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 {
|
||||||
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.args(&["-h", "127.0.0.1", "-p", "6379", "ping"]))
|
||||||
.and_then(|c| c.execute())
|
.and_then(|c| c.execute())
|
||||||
{
|
{
|
||||||
|
|
@ -148,24 +152,7 @@ pub fn cache_health_check() -> bool {
|
||||||
.and_then(|c| c.execute())
|
.and_then(|c| c.execute())
|
||||||
{
|
{
|
||||||
Ok(output) => output.status.success(),
|
Ok(output) => output.status.success(),
|
||||||
Err(_) => {
|
Err(_) => false,
|
||||||
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,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue