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.
This commit is contained in:
+15
-1
@@ -274,7 +274,21 @@ cmd_deploy() {
|
|||||||
if [ -f '$COMPOSE_FILE' ]; then
|
if [ -f '$COMPOSE_FILE' ]; then
|
||||||
$COMPOSE_CMD -f '$COMPOSE_FILE' build
|
$COMPOSE_CMD -f '$COMPOSE_FILE' build
|
||||||
$COMPOSE_CMD -f '$COMPOSE_FILE' up -d
|
$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
|
else
|
||||||
echo \"⚠️ 未找到 ${COMPOSE_FILE},跳过 Next.js 容器重建\"
|
echo \"⚠️ 未找到 ${COMPOSE_FILE},跳过 Next.js 容器重建\"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user