Files
zjpb.net/update.sh
Jowe a9a4f5f8e8 feat: 添加日常更新部署脚本 update.sh
git pull 拉取代码后自动 systemctl restart zjpb,并验证服务状态

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-23 23:16:28 +08:00

42 lines
885 B
Bash

#!/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 "=============================="