fix: wait for services during deployment
This commit is contained in:
@@ -89,9 +89,22 @@ systemctl restart cmpp-api
|
||||
systemctl restart nginx
|
||||
|
||||
echo "[deploy] Health checks"
|
||||
sleep 3
|
||||
curl -fsS "http://127.0.0.1:${API_PORT:-3000}/api/health" >/dev/null
|
||||
curl -fsS "http://127.0.0.1:8090/health" >/dev/null
|
||||
wait_for_http() {
|
||||
local name="$1"
|
||||
local url="$2"
|
||||
local attempt
|
||||
# Nest初始化和活动通道恢复会随生产数据量波动;固定等待会把正常的慢启动误判为发布失败。
|
||||
for attempt in $(seq 1 60); do
|
||||
if curl -fsS "$url" >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo "$name did not become healthy within 60 seconds: $url" >&2
|
||||
return 1
|
||||
}
|
||||
wait_for_http "API" "http://127.0.0.1:${API_PORT:-3000}/api/health"
|
||||
wait_for_http "Gateway" "http://127.0.0.1:8090/health"
|
||||
redis-cli -h "${REDIS_HOST:-127.0.0.1}" -p "${REDIS_PORT:-6379}" ping >/dev/null
|
||||
pg_isready -d "${DATABASE_URL%%\?*}" >/dev/null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user