fix: make HTTP check authoritative in healthcheck for container compatibility
Process detection fails in containers due to missing privileged tools (ss -p requires root, lsof often not installed). HTTP health endpoint is the reliable indicator of service health, so port/process checks are now informational only.
This commit is contained in:
@@ -56,7 +56,7 @@ check_port() {
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
health_log "WARN" "Neither ss nor netstat available for port checking"
|
health_log "WARN" "Neither ss nor netstat available for port checking"
|
||||||
return 1
|
return 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,11 +108,10 @@ check_process() {
|
|||||||
local cpu_time=$(awk '/utime|stime/ {sum+=$2} END {printf "%.2f seconds", sum/100}' "/proc/${pid}/status")
|
local cpu_time=$(awk '/utime|stime/ {sum+=$2} END {printf "%.2f seconds", sum/100}' "/proc/${pid}/status")
|
||||||
health_log "INFO" " CPU time: ${cpu_time}"
|
health_log "INFO" " CPU time: ${cpu_time}"
|
||||||
fi
|
fi
|
||||||
return 0
|
|
||||||
else
|
else
|
||||||
health_log "ERROR" "✗ ${service} process NOT found"
|
health_log "WARN" "⚠ ${service} process NOT found (may require privileges)"
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# System resource check
|
# System resource check
|
||||||
@@ -160,17 +159,13 @@ main() {
|
|||||||
|
|
||||||
# Check chat service (port 4500)
|
# Check chat service (port 4500)
|
||||||
health_log "INFO" "=== Chat Service (port 4500) ==="
|
health_log "INFO" "=== Chat Service (port 4500) ==="
|
||||||
if ! check_port 4500 "chat service"; then
|
check_port 4500 "chat service"
|
||||||
exit_code=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! check_http "http://localhost:4500/api/health" "chat service" 3; then
|
if ! check_http "http://localhost:4500/api/health" "chat service" 3; then
|
||||||
exit_code=1
|
exit_code=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! check_process "chat service" 4500; then
|
check_process "chat service" 4500
|
||||||
exit_code=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
health_log "INFO" "========== HEALTH CHECK END ==========="
|
health_log "INFO" "========== HEALTH CHECK END ==========="
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user