这样重启workerman进程是否有问题?

efnic

问题描述

后台管理界面,增减进程后重启整个服务

<?php
if (PHP_SAPI !== 'cli') {
    exit("You must run the CLI environment\n");
}
$rootPath = dirname(__DIR__);
$restartFile = $rootPath . '/runtime/restart.crontab';
if (is_file($restartFile) && unlink($restartFile)) {
    $cmd = 'cd ' . $rootPath . ' && php start.php restart -d';
    shell_exec($cmd);
    sleep(3);
}

利用Linux的定时任务,每分钟调用一次这个脚本;
脚本通过 is_file($restartFile) && unlink($restartFile),检查标志文件,重启整个服务。

570 1 1
1个回答

kspade

PHP Notice: fwrite(): Write of 127 bytes failed with errno=32 Broken pipe
vendor/workerman/workerman/Worker.php on line 2254

我用你这个方法。报错

  • efnic 2023-08-25

    rootPath 换成你自己的;
    命令行默认的php版本如果不确定的话,请使用绝对路径。

🔝