From e0d38de0e41b5dbb3665933389a67c493cb71bf7 Mon Sep 17 00:00:00 2001 From: liuwei Date: Wed, 30 Apr 2025 14:55:39 +0800 Subject: [PATCH] =?UTF-8?q?855=20=E5=8D=8F=E8=AE=AE=E7=89=88=E6=9C=AC-?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AE=8C=E6=AF=95=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- restart.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 restart.sh diff --git a/restart.sh b/restart.sh new file mode 100644 index 0000000..b852c49 --- /dev/null +++ b/restart.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# 进入项目目录 +cd /home/liuwei/wechatbot/WeChatRobot + +# 拉取最新代码 +git pull origin feature-855 # 根据需要拉取对应的分支 + +# 查找并杀死当前 main.py 进程 +CURRENT_PID=$(ps aux | grep 'main.py' | grep -v grep | awk '{print $2}') +if [ -n "$CURRENT_PID" ]; then + echo "Killing the existing main.py process (PID: $CURRENT_PID)" + kill -9 $CURRENT_PID +else + echo "No running main.py process found." +fi + +# 重新启动 main.py +echo "Restarting main.py..." +python main.py &