diff --git a/update.sh b/update.sh new file mode 100644 index 0000000..2422f8a --- /dev/null +++ b/update.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# ZJPB 更新部署脚本 +# 用法: ./update.sh +# 功能: git pull 拉取最新代码,然后重启服务 + +set -e + +APP_DIR="/opt/1panel/apps/zjpb" +SERVICE_NAME="zjpb" + +echo "==============================" +echo " ZJPB 更新部署" +echo "==============================" + +cd "$APP_DIR" + +# 1. 拉取最新代码 +echo "[1/3] 拉取最新代码..." +git pull +echo " 完成" + +# 2. 重启服务 +echo "[2/3] 重启服务..." +systemctl restart "$SERVICE_NAME" +echo " 完成" + +# 3. 验证服务状态 +echo "[3/3] 验证服务状态..." +sleep 2 +if systemctl is-active --quiet "$SERVICE_NAME"; then + echo " 服务运行正常" +else + echo " [错误] 服务启动失败,查看日志:" + journalctl -u "$SERVICE_NAME" -n 20 --no-pager + exit 1 +fi + +echo "" +echo "==============================" +echo " 部署完成" +echo "=============================="