File tree Expand file tree Collapse file tree 1 file changed +20
-5
lines changed
Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -106,20 +106,35 @@ jobs:
106106 echo "⏳ 等待服务启动..."
107107 sleep 10
108108
109- # 健康检查(重试机制)
109+ # 检查服务状态
110+ if ! systemctl is-active --quiet tinyflow; then
111+ echo "❌ 服务未运行,查看日志:"
112+ journalctl -u tinyflow -n 100
113+ exit 1
114+ fi
115+
116+ echo "✅ systemd服务已启动,等待应用完全就绪..."
117+
118+ # 健康检查(重试机制,不强制要求200状态码)
110119 MAX_RETRY=12
111120 RETRY_COUNT=0
112121 while [ $RETRY_COUNT -lt $MAX_RETRY ]; do
113- if curl -f http://localhost:8080/actuator/health > /dev/null 2>&1; then
114- echo "✅ 部署完成!服务已启动"
122+ HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/actuator/health)
123+ if [ "$HTTP_CODE" = "200" ]; then
124+ echo "✅ 部署完成!服务健康检查通过 (HTTP $HTTP_CODE)"
115125 exit 0
126+ elif [ "$HTTP_CODE" != "000" ]; then
127+ echo "⚠️ 服务响应但状态不是OK (HTTP $HTTP_CODE),继续等待..."
116128 fi
117129 RETRY_COUNT=$((RETRY_COUNT+1))
118- echo "⏳ 第 $RETRY_COUNT 次检查失败 ,等待 10 秒后重试..."
130+ echo "⏳ 第 $RETRY_COUNT/$MAX_RETRY 次检查 ,等待 10 秒后重试..."
119131 sleep 10
120132 done
121133
122- echo "❌ 服务启动超时,请检查日志"
134+ echo "❌ 健康检查超时,最后状态码: $HTTP_CODE"
135+ echo "检查服务端口监听状态:"
136+ ss -tlnp | grep 8080 || netstat -tlnp | grep 8080 || echo "未找到监听8080端口的进程"
137+ echo "查看服务日志:"
123138 journalctl -u tinyflow -n 100
124139 exit 1
125140
You can’t perform that action at this time.
0 commit comments