Laravel queue 使用supervisor 實現多執行序
https://segmentfault.com/a/1190000021165798
[program:laravel-queue-work]
process_name=%(program_name)s_%(process_num)02d
directory=/data/yoursite
command=php artisan queue:work
autostart=true
autorestart=true
user=www
numprocs=32
redirect_stderr=true
安裝supervisor
yum install -y supervisor
修改設定檔 vim /etc/supervisord.conf
[include]
files = supervisord.d/*.conf
;files = supervisord.d/*.ini 改成 files = supervisord.d/*.conf
新增 laravel-queue-work.conf
vim /etc/supervisord.d/laravel-queue-work.conf
[program:laravel-queue-work]
process_name=%(program_name)s_%(process_num)02d
directory=/usr/share/nginx/html/laravel5/webmon
command=php artisan queue:work
autostart=true
autorestart=true
user=nginx
numprocs=50
;stdout_logfile = /etc/supervisor.d/log/laravel-queue.log
;stderr_logfile = /etc/supervisor.d/log/laravel-queue_err.log
redirect_stderr=true
[supervisord]
常用指令
#執行 supervisor
#supervisord
#supervisord -c /etc/supervisord.d/laravel-queue-work.conf (指令config)
[root@aaa]# supervisord
/usr/lib/python2.7/site-packages/supervisor/options.py:461: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
'Supervisord is running as root and it is searching '
#顯示執行 目前沒有執行
[root@a1-gcm12 etc]# supervisorctl status
unix:///var/run/supervisor/supervisor.sock no such file
#顯示執行 (目前執行)
[root@a1-gcm12 etc]# supervisorctl status
laravel-queue-work:laravel-queue-work_00 RUNNING pid 28389, uptime 0:00:20
laravel-queue-work:laravel-queue-work_01 RUNNING pid 28388, uptime 0:00:20
laravel-queue-work:laravel-queue-work_02 RUNNING pid 28391, uptime 0:00:20
#修改設定檔後重新載入
[root@a1-gcm12 etc]# supervisorctl reload
#停用 supervisor
[root@aaa]# supervisorctl shutdown
Shut down