安装:sudo apt-get install supervisor
启动:service supervisor start
配置修改
- cd /etc/supervisor/conf.d文件夹下创建laravel-worker.conf
```
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php 项目路径/artisan queue:work 队列名称[redis/rabbitmq/sqs] --sleep=3 --tries=3
autostart=true
autorestart=true
user=forge -- 需改为root
numprocs=8
redirect_stderr=true
stdout_logfile=日志路径[一般:/var/log/laravel-worker.log]
```
> numprocs指令让 Supervisor 运行 8 个queue:work进程并监视它们,如果失败的话自动重启。
启动
```
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-worker:*
```
安装问题
* 上述问题为laravel-worker.conf文件中user用户名称错误导致,应将forge修改为root
其余
* 启动完毕查看日志看队列执行情况:tail -f /var/log/laravel-worker.log