From a9a4f5f8e8c52bd34da9c98b0da89c9290cc2b8c Mon Sep 17 00:00:00 2001 From: Jowe <123822645+Selei1983@users.noreply.github.com> Date: Mon, 23 Feb 2026 23:16:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=B8=B8?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=83=A8=E7=BD=B2=E8=84=9A=E6=9C=AC=20update?= =?UTF-8?q?.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git pull 拉取代码后自动 systemctl restart zjpb,并验证服务状态 Co-Authored-By: Claude Sonnet 4.6 --- update.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 update.sh 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 "=============================="