From f14b82ab6338476cc44f25c9a3232d208a649782 Mon Sep 17 00:00:00 2001 From: zhangxiang Date: Tue, 18 Aug 2026 13:11:11 +0800 Subject: [PATCH] fix(deploy): wait for Next.js container readiness before verification The container can still be booting when Nginx starts proxying, causing a temporary 502 in the post-deploy verification. Poll localhost:3000 for up to 60s after recreating the container. --- scripts/deploy.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index f46fdd8..89304a5 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -274,7 +274,21 @@ cmd_deploy() { if [ -f '$COMPOSE_FILE' ]; then $COMPOSE_CMD -f '$COMPOSE_FILE' build $COMPOSE_CMD -f '$COMPOSE_FILE' up -d - echo \"✅ Next.js 容器已重建\" + echo \"✅ Next.js 容器已重建,等待就绪...\" + READY=0 + for i in \$(seq 1 30); do + if curl -fsS -o /dev/null --max-time 3 http://127.0.0.1:3000/ 2>/dev/null; then + READY=1 + break + fi + sleep 2 + done + if [ \"\$READY\" = \"1\" ]; then + echo \"✅ $NEXTJS_CONTAINER 就绪\" + else + echo \"❌ $NEXTJS_CONTAINER 未就绪,请检查容器日志\" + exit 1 + fi else echo \"⚠️ 未找到 ${COMPOSE_FILE},跳过 Next.js 容器重建\" fi