From e370b69d37cfa4cb8e3c4d2b2d7402ce23dd1dba Mon Sep 17 00:00:00 2001 From: ASUS <515617283@qq.com> Date: Thu, 23 Oct 2025 10:57:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- restart_services.sh | 34 +++++++++++++++++++++ start_webman_commands.php | 62 --------------------------------------- 2 files changed, 34 insertions(+), 62 deletions(-) create mode 100644 restart_services.sh delete mode 100644 start_webman_commands.php diff --git a/restart_services.sh b/restart_services.sh new file mode 100644 index 0000000..efe9852 --- /dev/null +++ b/restart_services.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# 切换到目标目录 +cd /rh/p_ysk/ || { + echo "错误:无法切换到目录 /rh/p_ysk/" + exit 1 +} + +# 停止 webman 相关命令 +echo "执行 stop_webman_commands.php..." +php stop_webman_commands.php + +# 停止 webman 服务 +echo "停止 webman 服务..." +php start.php stop + +# 启动 webman 服务(后台模式) +echo "启动 webman 服务(后台模式)..." +php start.php start -d + +# 启动各类 webman 进程(后台运行) +echo "启动 applysmstemp 进程..." +nohup php webman applysmstemp & + +echo "启动 birthdaygiftsms 进程..." +nohup php webman birthdaygiftsms & + +echo "启动 rabborderprint 进程..." +nohup php webman rabborderprint & + +echo "启动 rabbproductupdate 进程..." +nohup php webman rabbproductupdate & + +echo "所有命令执行完成" diff --git a/start_webman_commands.php b/start_webman_commands.php deleted file mode 100644 index c2591cd..0000000 --- a/start_webman_commands.php +++ /dev/null @@ -1,62 +0,0 @@ - ./logs/applysmstemp.log 2>&1 & setsid $!', - 'nohup php webman birthdaygiftsms & > ./logs/birthdaygiftsms.log 2>&1 & setsid $!', - 'nohup php webman rabborderprint & > ./logs/rabborderprint.log 2>&1 & setsid $!', - 'nohup php webman rabbproductupdate & > ./logs/rabbproductupdate.log 2>&1 & setsid $!', - - // 若为 Windows 系统,替换为以下命令(start /b 后台运行,输出重定向) - // 'start /b nohup php webman applysmstemp > ./logs/applysmstemp.log 2>&1', - // 'start /b nohup php webman birthdaygiftsms > ./logs/birthdaygiftsms.log 2>&1', - // 'start /b nohup php webman rabborderprint > ./logs/rabborderprint.log 2>&1', - // 'start /b nohup php webman rabbproductupdate > ./logs/rabbproductupdate.log 2>&1', -]; - -// 2. 提前创建日志目录(避免日志写入失败) -$logDir = './logs'; -if (!is_dir($logDir)) { - mkdir($logDir, 0755, true); // 0755 是目录权限,true 支持创建多级目录 - echo "已创建日志目录:{$logDir}\n"; -} - -// 3. 批量执行命令(非阻塞) -echo "开始启动 Webman 进程...\n"; -echo "----------------------------------------\n"; - -foreach ($commands as $index => $cmd) { - $commandNum = $index + 1; - echo "执行命令 {$commandNum}: {$cmd}\n"; - - // 关键:用 proc_open 替代 shell_exec,强制关闭终端关联,避免阻塞 - $descriptors = [ - 0 => ['pipe', 'r'], // 标准输入(关闭,避免占用) - 1 => ['pipe', 'w'], // 标准输出(忽略) - 2 => ['pipe', 'w'] // 标准错误(忽略) - ]; - $process = proc_open($cmd, $descriptors, $pipes); - if (is_resource($process)) { - // 关闭所有管道,彻底脱离终端 - fclose($pipes[0]); - fclose($pipes[1]); - fclose($pipes[2]); - // 不等待进程结束(避免阻塞) - proc_close($process); - echo "命令 {$commandNum} 启动成功(后台运行,日志见 ./logs/)\n"; - } else { - echo "命令 {$commandNum} 启动失败!\n"; - } - echo "----------------------------------------\n"; -} - -echo "所有命令执行完毕!\n"; -echo "查看进程:ps aux | grep webman\n"; -echo "查看日志:cat ./logs/[进程名].log\n"; -echo "停止进程:kill [进程ID]\n"; \ No newline at end of file