supervisor 启动 gatewaywork 报错问题

lacorey

启动配置文件

process_name=%(program_name)s_%(process_num)02d
command=/usr/local/php/bin/php /workspace/dev0/ctjy_socket_server/start.php start -d
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/workspace/dev0/ctjy_socket_server/storage/logs/worker.log

然后启动时 $ supervisorctl start all
ctjypt-socket-server_00: ERROR (abnormal termination)

查看日志发现

Fatal error: Uncaught Exception: can not save pid to /var/run/workerman.pid in /workspace/dev0/ctjy_socket_server/vendor/workerman/workerman/Worker.php:1031
Stack trace:
#0 /workspace/dev0/ctjy_socket_server/vendor/workerman/workerman/Worker.php(457): Workerman\Worker::saveMasterPid()
#1 /workspace/dev0/ctjy_socket_server/start.php(41): Workerman\Worker::runAll()
#2 {main}
  thrown in /workspace/dev0/ctjy_socket_server/vendor/workerman/workerman/Worker.php on line 1031
``

试图修改 $ chmod -R 777 /var/run/ 也不行

然后配置 启动文件 

```php
require_once __DIR__ . '/vendor/autoload.php';

Worker::$pidFile = __DIR__ . '/storage/workerman.pid';

还是报上面一样的错误

Fatal error: Uncaught Exception: can not save pid to /var/run/workerman.pid

但是 php start.php status 又显示启动了

如果 直接在控制台输入 php start.php start -d 则没有任务问题

请问使用supervisor 守护怎么操作

8008 3 0
3个回答

six

很明显啊,supervisor 没权限在 /var/run/目录添加文件或者修改文件 /var/run/workerman.pid

  • lacorey 2018-04-04

    这个又怎么解释呢 Worker::$pidFile = __DIR__ . '/storage/workerman.pid';

  • six 2018-04-04

    所有文件代码里找关键字 /var/run/ 呗,应该是哪里还设置了Worker::$pidFile

lacorey

现在发现 如果是在控制台运行
发现 /workspace/dev0/ctjy_socket_server/storage/workerman.pid 配置已经生效了
不知道为什么 supervisor 会不按配置里的走 会把它住 /var/run 里保存

  • 暂无评论
lacorey

cat /var/log/supervisor/supervisord.log

2018-04-04 14:20:18,796 INFO spawned: 'ctjypt-socket-server_00' with pid 14772
2018-04-04 14:20:18,835 INFO exited: ctjypt-socket-server_00 (exit status 0; not expected)
2018-04-04 14:20:19,836 INFO gave up: ctjypt-socket-server_00 entered FATAL state, too many start retries too quickly

  • jingwentian 2018-06-04

    supervisord 不能管理后台运行程序,启动 workerman 的时候需要设置为:Worker::$daemonize = false

年代过于久远,无法发表回答
×
🔝