From 18b3bcb66216af53eca9230be527313e02731c50 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 30 Aug 2026 14:13:12 +0000 Subject: [PATCH] fix: check profiled PostgreSQL readiness --- install.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index a606dc1..1b0782a 100644 --- a/install.sh +++ b/install.sh @@ -190,12 +190,16 @@ if [[ $PG_HOST == postgres ]]; then run_logged "${COMPOSE[@]}" --profile local-d if [[ $PG_HOST == postgres ]]; then ready=0 for elapsed in $(seq 0 118 2); do - "${COMPOSE[@]}" --project-directory "$INSTALL_DIR" --env-file "$INSTALL_DIR/.env" -f "$INSTALL_DIR/compose.yaml" exec -T postgres pg_isready -U "$PG_USER" -d "$PG_DB" >/dev/null 2>&1 && { ready=1; break; } + "${COMPOSE[@]}" --profile local-db --project-directory "$INSTALL_DIR" --env-file "$INSTALL_DIR/.env" -f "$INSTALL_DIR/compose.yaml" exec -T postgres pg_isready -U "$PG_USER" -d "$PG_DB" >/dev/null 2>&1 && { ready=1; break; } printf '\033[2K\r[%d/%d] 等待 PostgreSQL 就绪(%s 秒)' "$STEP" "$TOTAL_STEPS" "$elapsed" sleep 2 done printf '\n' - [[ $ready = 1 ]] || die 'PostgreSQL 未在限定时间内就绪' + if [[ $ready != 1 ]]; then + printf '\n--- PostgreSQL 容器日志 ---\n' >>"$INSTALL_LOG" + "${COMPOSE[@]}" --profile local-db --project-directory "$INSTALL_DIR" --env-file "$INSTALL_DIR/.env" -f "$INSTALL_DIR/compose.yaml" logs postgres >>"$INSTALL_LOG" 2>&1 || true + die 'PostgreSQL 未在限定时间内就绪' + fi fi progress '初始化数据库结构' if (( EXISTING_DB )); then export XYMEDIA_EXTERNAL_MIGRATION_CONFIRM=YES; run_logged "${COMPOSE[@]}" --profile migration --project-directory "$INSTALL_DIR" --env-file "$INSTALL_DIR/.env" -f "$INSTALL_DIR/compose.yaml" run --rm --no-deps app-migrate migrate --config /app/config.yaml || die '已有数据库迁移失败'; else run_logged "${COMPOSE[@]}" --profile migration --project-directory "$INSTALL_DIR" --env-file "$INSTALL_DIR/.env" -f "$INSTALL_DIR/compose.yaml" run --rm --no-deps app-migrate migrate --new --config /app/config.yaml || die '数据库初始化失败'; fi