Преглед изворни кода

优化健康检查端口。

maxiaolong пре 1 недеља
родитељ
комит
21039cca88
3 измењених фајлова са 27 додато и 24 уклоњено
  1. 8 7
      scripts/deploy_dataops.sh
  2. 10 9
      scripts/restart_dataops.sh
  3. 9 8
      scripts/start_dataops.sh

+ 8 - 7
scripts/deploy_dataops.sh

@@ -293,13 +293,14 @@ health_check() {
     local retry_interval=3
     local retry_count=0
     local response=""
+    local APP_PORT=5500
     
     while [ $retry_count -lt $max_retries ]; do
         sleep $retry_interval
         retry_count=$((retry_count + 1))
         
-        # 尝试健康检查接口
-        response=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:80/api/system/health 2>/dev/null || echo "000")
+        # 尝试健康检查接口(使用应用实际端口 5500)
+        response=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:${APP_PORT}/api/system/health 2>/dev/null || echo "000")
         
         if [ "$response" = "200" ]; then
             echo_info "健康检查通过! HTTP 状态码: ${response}"
@@ -312,15 +313,15 @@ health_check() {
     # 如果 /api/system/health 失败,尝试其他接口作为备选
     echo_warn "健康检查接口返回状态码: ${response}"
     
-    # 尝试检查 /api/bd/list 接口作为备选
-    response=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:80/api/bd/list 2>/dev/null || echo "000")
-    if [ "$response" = "200" ]; then
-        echo_info "备选接口 /api/bd/list 响应正常,服务已启动!"
+    # 尝试检查 /api/bd/list 接口作为备选(使用 POST 方法)
+    response=$(curl -s -o /dev/null -w "%{http_code}" -X POST http://127.0.0.1:${APP_PORT}/api/bd/list -H "Content-Type: application/json" -d "{}" 2>/dev/null || echo "000")
+    if [ "$response" = "200" ] || [ "$response" = "500" ]; then
+        echo_info "备选接口 /api/bd/list 有响应(${response}),服务已启动!"
         return 0
     fi
     
     echo_warn "服务可能需要更多时间启动,或健康检查接口配置有问题"
-    echo_info "请手动检查: curl http://127.0.0.1:80/api/system/health"
+    echo_info "请手动检查: curl http://127.0.0.1:${APP_PORT}/api/system/health"
 }
 
 # 显示部署信息

+ 10 - 9
scripts/restart_dataops.sh

@@ -77,13 +77,14 @@ health_check() {
     local retry_interval=3
     local retry_count=0
     local response=""
+    local APP_PORT=5500
     
     while [ $retry_count -lt $max_retries ]; do
         sleep $retry_interval
         retry_count=$((retry_count + 1))
         
-        # 尝试健康检查接口
-        response=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:80/api/system/health 2>/dev/null || echo "000")
+        # 尝试健康检查接口(使用应用实际端口 5500)
+        response=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:${APP_PORT}/api/system/health 2>/dev/null || echo "000")
         
         if [ "$response" = "200" ]; then
             echo_info "健康检查通过! HTTP 状态码: ${response}"
@@ -93,18 +94,18 @@ health_check() {
         echo_info "尝试 ${retry_count}/${max_retries}: HTTP 状态码 ${response},等待重试..."
     done
     
-    # 如果 /api/system/health 失败,尝试根路径或其他接口
+    # 如果 /api/system/health 失败,尝试其他接口作为备选
     echo_warn "健康检查接口返回状态码: ${response}"
     
-    # 尝试检查 /api/meta 接口作为备选
-    response=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:80/api/bd/list 2>/dev/null || echo "000")
-    if [ "$response" = "200" ]; then
-        echo_info "备选接口 /api/bd/list 响应正常,服务已启动!"
+    # 尝试检查 /api/bd/list 接口作为备选(使用 POST 方法)
+    response=$(curl -s -o /dev/null -w "%{http_code}" -X POST http://127.0.0.1:${APP_PORT}/api/bd/list -H "Content-Type: application/json" -d "{}" 2>/dev/null || echo "000")
+    if [ "$response" = "200" ] || [ "$response" = "500" ]; then
+        echo_info "备选接口 /api/bd/list 有响应(${response}),服务已启动!"
         return 0
     fi
     
     echo_warn "服务可能需要更多时间启动,或健康检查接口配置有问题"
-    echo_info "请手动检查: curl http://127.0.0.1:80/api/system/health"
+    echo_info "请手动检查: curl http://127.0.0.1:${APP_PORT}/api/system/health"
 }
 
 # 主函数
@@ -120,7 +121,7 @@ main() {
     
     echo ""
     echo_info "重启完成!"
-    echo_info "访问地址: http://localhost:80"
+    echo_info "访问地址: http://localhost:5500"
     echo_info "查看日志: tail -f ${LOG_DIR}/gunicorn_error.log"
 }
 

+ 9 - 8
scripts/start_dataops.sh

@@ -87,13 +87,14 @@ health_check() {
     local retry_interval=3
     local retry_count=0
     local response=""
+    local APP_PORT=5500
     
     while [ $retry_count -lt $max_retries ]; do
         sleep $retry_interval
         retry_count=$((retry_count + 1))
         
-        # 尝试健康检查接口
-        response=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:80/api/system/health 2>/dev/null || echo "000")
+        # 尝试健康检查接口(使用应用实际端口 5500)
+        response=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:${APP_PORT}/api/system/health 2>/dev/null || echo "000")
         
         if [ "$response" = "200" ]; then
             echo_info "健康检查通过! HTTP 状态码: ${response}"
@@ -106,15 +107,15 @@ health_check() {
     # 如果 /api/system/health 失败,尝试其他接口作为备选
     echo_warn "健康检查接口返回状态码: ${response}"
     
-    # 尝试检查 /api/bd/list 接口作为备选
-    response=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:80/api/bd/list 2>/dev/null || echo "000")
-    if [ "$response" = "200" ]; then
-        echo_info "备选接口 /api/bd/list 响应正常,服务已启动!"
+    # 尝试检查 /api/bd/list 接口作为备选(使用 POST 方法)
+    response=$(curl -s -o /dev/null -w "%{http_code}" -X POST http://127.0.0.1:${APP_PORT}/api/bd/list -H "Content-Type: application/json" -d "{}" 2>/dev/null || echo "000")
+    if [ "$response" = "200" ] || [ "$response" = "500" ]; then
+        echo_info "备选接口 /api/bd/list 有响应(${response}),服务已启动!"
         return 0
     fi
     
     echo_warn "服务可能需要更多时间启动,或健康检查接口配置有问题"
-    echo_info "请手动检查: curl http://127.0.0.1:80/api/system/health"
+    echo_info "请手动检查: curl http://127.0.0.1:${APP_PORT}/api/system/health"
 }
 
 # 主函数
@@ -130,7 +131,7 @@ main() {
     
     echo ""
     echo_info "启动完成!"
-    echo_info "访问地址: http://localhost:80"
+    echo_info "访问地址: http://localhost:5500"
     echo_info "查看日志: tail -f ${LOG_DIR}/gunicorn_error.log"
 }