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:
southseact-3d
2026-02-13 09:39:58 +00:00
parent 098e971151
commit 55ee592379

View File

@@ -56,7 +56,7 @@ check_port() {
fi
else
health_log "WARN" "Neither ss nor netstat available for port checking"
return 1
return 0
fi
}
@@ -108,11 +108,10 @@ check_process() {
local cpu_time=$(awk '/utime|stime/ {sum+=$2} END {printf "%.2f seconds", sum/100}' "/proc/${pid}/status")
health_log "INFO" " CPU time: ${cpu_time}"
fi
return 0
else
health_log "ERROR" " ${service} process NOT found"
return 1
health_log "WARN" " ${service} process NOT found (may require privileges)"
fi
return 0
}
# System resource check
@@ -160,17 +159,13 @@ main() {
# Check chat service (port 4500)
health_log "INFO" "=== Chat Service (port 4500) ==="
if ! check_port 4500 "chat service"; then
exit_code=1
fi
check_port 4500 "chat service"
if ! check_http "http://localhost:4500/api/health" "chat service" 3; then
exit_code=1
fi
if ! check_process "chat service" 4500; then
exit_code=1
fi
check_process "chat service" 4500
health_log "INFO" "========== HEALTH CHECK END ==========="