supervisor 管理 laravel queue 進程

請注意 要使用numprocs=8 進程池的概念,須要使用 supervisor 3.0版本以上

有的時候咱們須要監控一個PHP進程 ,好比 laravel queue 若是掛了自動拉起來.
supervisor 能夠幫咱們作好這件事情php

安裝supervisor

本人使用的是 centos 7
yum install python-setuptools
easy_install supervisor

安裝以後進行一些簡單的的配置

echo_supervisord_conf > /etc/supervisord.conf
vi /etc/supervisord.conf
;監控程序名字
[program:cptn-queue-listener]
process_name=%(program_name)s_%(process_num)02d

;要用 supervisor 管理的程序指令
command=php /data/src/cptn/artisan queue:work --tries=3

;是否自動啓動
autostart=true

;是否自動重啓動
autorestart=true
numprocs=8
user=www
;是否重定向錯誤
redirect_stderr=true

;重定向到指定路徑的日誌文件
stdout_logfile=/data/wwwlogs/queue-listener.log

啓動supervisor

supervisord

而後檢查一下 進程是否有啓動python

ps -ef | grep artisan


root     13675 13673  1 11:00 ?        00:00:00 php /data/src/cptn/artisan queue:listen --tries=3
root     13720 13675  6 11:01 ?        00:00:00 /usr/local/php/bin/php artisan queue:work  --once --queue=default --delay=0 --memory=128 --sleep=3 --tries=3 --env=local

完...laravel

相關文章
相關標籤/搜索