From 0fda3af4c35275f8d98b7720e4c60c15a219e1fb Mon Sep 17 00:00:00 2001 From: root Date: Fri, 4 Sep 2026 14:20:54 +0000 Subject: [PATCH] fix(deploy): wait for control proxy health --- SHA256SUMS | 2 +- install.sh | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/SHA256SUMS b/SHA256SUMS index 31166a3..ff8ccab 100644 --- a/SHA256SUMS +++ b/SHA256SUMS @@ -1,4 +1,4 @@ -8cc23c8ac0b407deec4bd2c10f98ce1dae7b97c7fa8193b28773607680075a77 install.sh +3776581f5b8755afe0fbc3ea9121416504f117da83f2baa6214c315d2d473ef8 install.sh e8cabc5a989d171206361e6ae8b4e0baf9bb9a611ac41106bbe42de0782e8975 compose/s.yml 203b6da918dee21dbfabbcf5466111bd92c7a8c9e754dad61e7e75e20513b880 compose/e.yml c226c5e1feb5cd6948ee9b32897e77240e21793090d8f42234ca999450ec90b0 config/e-server.production.yaml diff --git a/install.sh b/install.sh index f69acdb..bde1782 100755 --- a/install.sh +++ b/install.sh @@ -349,11 +349,28 @@ rm -f "$image_tar" mv "$image_archive" "$ROOT/node-images/media-node.tar.gz" chmod 644 "$ROOT/node-images/media-node.tar.gz" +wait_for_compose_health() { + compose_file=$1; project=$2; service=$3; attempt=1 + while [ "$attempt" -le 60 ]; do + container=$(docker compose --env-file "$ENV_FILE" -f "$compose_file" -p "$project" ps -q "$service" 2>/dev/null || true) + status='' + if [ -n "$container" ]; then + status=$(docker inspect -f '{{.State.Health.Status}}' "$container" 2>/dev/null || true) + fi + [ "$status" = healthy ] && return 0 + [ "$status" = unhealthy ] && die "$service 容器健康检查失败" + sleep 2 + attempt=$((attempt + 1)) + done + die "$service 容器健康检查超时" +} + docker compose --env-file "$ENV_FILE" -f "$E_COMPOSE" -p "$E_PROJECT" up -d postgres valkey docker compose --env-file "$ENV_FILE" -f "$E_COMPOSE" -p "$E_PROJECT" run --rm --no-deps e-server migrate -config /etc/overcooked-e/config.yaml docker compose --env-file "$ENV_FILE" -f "$S_COMPOSE" -p "$S_PROJECT" up -d postgres valkey docker compose --env-file "$ENV_FILE" -f "$S_COMPOSE" -p "$S_PROJECT" run --rm --no-deps s-migrate docker compose --env-file "$ENV_FILE" -f "$S_COMPOSE" -p "$S_PROJECT" up -d s-control control-proxy webui +wait_for_compose_health "$S_COMPOSE" "$S_PROJECT" control-proxy docker compose --env-file "$ENV_FILE" -f "$E_COMPOSE" -p "$E_PROJECT" up -d e-server wait_for() {