fix: check profiled PostgreSQL readiness
This commit is contained in:
+6
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user