From b8b04189926f7b8952a668bb03ba1eadd74e22d1 Mon Sep 17 00:00:00 2001 From: zhangtao <9480807882@qq.com> Date: Mon, 26 May 2025 01:11:01 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4API=E5=81=A5?= =?UTF-8?q?=E5=BA=B7=E6=A3=80=E6=9F=A5=E5=B9=B6=E8=B0=83=E6=95=B4=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E8=84=9A=E6=9C=AC=E6=AD=A5=E9=AA=A4=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除不再需要的API_URL变量及相关健康检查 - 将停止容器步骤提前到构建前端之前 - 调整日志中的步骤编号以保持一致性 - 移除部署完成时多余的API文档日志 --- start.sh | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/start.sh b/start.sh index 0a09ca93..619ca54d 100644 --- a/start.sh +++ b/start.sh @@ -5,7 +5,6 @@ PROJECT_NAME="fastapi_vue3_admin" WORK_DIR="/home" GIT_REPO="https://gitee.com/tao__tao/fastapi_vue3_admin.git" WEB_URL="http://8.137.99.5:80" -API_URL="http://8.137.99.5:8001/api/v1/docs" # 打印带时间戳的日志 log() { @@ -47,9 +46,17 @@ update_code() { fi } +# 停止并删除容器 +stop_and_remove_containers() { + log "==========🗑️ 第四五步:停止并删除现有容器...==========" + [ -f "docker-compose.yaml" ] || { log "❌ docker-compose.yaml 文件未找到"; exit 1; } + docker compose down + log "✅ 容器已停止并删除" +} + # 构建前端 build_frontend() { - log "==========🔍 第四步:开始构建前端代码...==========" + log "==========🔍 第五步:开始构建前端代码...==========" # 如果是首次克隆项目,或者检测到前端代码变更,则构建前端 if [ ! -d "frontend/dist" ] || [ "$(git diff --name-only HEAD~1 HEAD -- frontend/)" ]; then log "🚀 检测到前端代码变更或首次克隆,开始构建前端..." @@ -63,14 +70,6 @@ build_frontend() { fi } -# 停止并删除容器 -stop_and_remove_containers() { - log "==========🗑️ 第五步:停止并删除现有容器...==========" - [ -f "docker-compose.yaml" ] || { log "❌ docker-compose.yaml 文件未找到"; exit 1; } - docker compose down - log "✅ 容器已停止并删除" -} - # 构建镜像 build_image() { log "==========🚀 第六步:开始构建Docker镜像...==========🗑️ " @@ -90,8 +89,6 @@ health_check() { log "==========🔍 第八步:进行健康检查...==========🗑️ " sleep 10 # 等待容器启动 curl --output /dev/null --silent --head --fail "${WEB_URL}" || { log "❌ 前端服务健康检查失败"; exit 1; } - sleep 10 # 等待容器启动 - curl --output /dev/null --silent --head --fail "${API_URL}" || { log "❌ 后端服务健康检查失败"; exit 1; } log "✅ 服务健康检查通过" } @@ -115,7 +112,6 @@ main() { health_check cleanup_old_images log "==========🎉 【部署完成】访问地址: ${WEB_URL}==========" - log "==========🎉 【API文档】访问地址: ${API_URL}==========" } main