fix: honor custom HTTP bind in health checks

This commit is contained in:
zxyszx
2026-08-03 16:49:33 +08:00
parent 65bc16bd92
commit 6059954596
+6 -3
View File
@@ -157,9 +157,12 @@ prepare_directories() {
} }
wait_for_health() { wait_for_health() {
local attempts="${1:-60}" local attempts="${1:-60}" bind port
bind="$(env_value LANQIN_HTTP_BIND || true)"
bind="${bind:-80}"
port="${bind##*:}"
for ((i=1; i<=attempts; i++)); do for ((i=1; i<=attempts; i++)); do
if curl -fsS --max-time 3 http://127.0.0.1/healthz >/dev/null 2>&1; then if curl -fsS --max-time 3 "http://127.0.0.1:${port}/healthz" >/dev/null 2>&1; then
return 0 return 0
fi fi
sleep 2 sleep 2
@@ -237,7 +240,7 @@ do_rollback() {
do_status() { do_status() {
[[ -f "${INSTALL_DIR}/docker-compose.yml" ]] || fail "尚未安装。" [[ -f "${INSTALL_DIR}/docker-compose.yml" ]] || fail "尚未安装。"
compose ps compose ps
if curl -fsS --max-time 3 http://127.0.0.1/healthz >/dev/null 2>&1; then if wait_for_health 1; then
success "Web 与 API 健康检查正常。" success "Web 与 API 健康检查正常。"
else else
fail "健康检查失败。" fail "健康检查失败。"