Centos 7 安装Supervisor管理Laravel Queue | ICHARM

首页 » 博文 » Linux » 正文

Centos 7 安装Supervisor管理Laravel Queue

文章目录

参考中有laravel官方文档关于supervisor的配置和使用,但是是基于Ubuntu,和Centos有一些差别。

安装

直接使用 yum进行安装,最好安装3以上的版本

# yum info supervisor
# yum install supervisor

配置

编辑配置文件

# vim /etc/supervisord.conf

在最后面添加下面内容:

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /home/forge/app.com/artisan queue:work --tries=3
autostart=true
autorestart=true
user=forge //注意这里队列以什么用户权限运行
numprocs=8 //启动多少个进程
redirect_stderr=true
stdout_logfile=/home/forge/app.com/worker.log

执行 supervisord启动supervisord服务。

# supervisord
...
 'Supervisord is running as root and it is searching '
...

执行下面命令,启动上面配置好的laravel队列

# supervisorctl start laravel-worker:*

当Job代码变动时,需要重新启动队列

# supervisorctl restart laravel-worker:*
laravel-worker:laravel-worker_00: stopped
laravel-worker:laravel-worker_01: stopped
laravel-worker:laravel-worker_02: stopped
laravel-worker:laravel-worker_03: stopped
laravel-worker:laravel-worker_04: stopped
laravel-worker:laravel-worker_05: stopped
laravel-worker:laravel-worker_06: stopped
laravel-worker:laravel-worker_07: stopped
laravel-worker:laravel-worker_00: started
laravel-worker:laravel-worker_01: started
laravel-worker:laravel-worker_02: started
laravel-worker:laravel-worker_03: started
laravel-worker:laravel-worker_04: started
laravel-worker:laravel-worker_05: started
laravel-worker:laravel-worker_06: started
laravel-worker:laravel-worker_07: started

 

参考

https://docs.golaravel.com/docs/5.4/queues/#supervisor-configuration

发表评论