Centos 8 透過 Supervisor 監控 Laravel queue 執行工作

Jerry Chen
Sep 11, 2020

--

在系統即時發送信件時會導致使用者卡在等待伺服器回應的狀態,因此透過 queue 將信件發送加入資料表 jobs 內,延遲發送信件,讓使用體驗更加流暢,關於 Laravel queue 的使用方式請參閱 Laravel 文件。

安裝 supervisor

yum install supervisor

配置 /etc/supervisor.conf

[program:laravel-worker]
command=php /var/www/html/project/artisan queue:work — queue=email — daemon — memory 256
process_name=%(program_name)s_%(process_num)02d
numprocs=1
priority=999
autostart=true
autorestart=true
startsecs=1
startretries=3
user=nginx

參數說明
1. command:根據 Laravel 專案目錄執行 artisan queue 指令
2. numprocs:數字越大處理速度越快,但相對的更吃 CPU、記憶體,根據工作調整數據

配置參數完成後啟用 supervisor

systemctl start supervisord.service

其他指令
開機自動啟用:systemctl enable supervisord.service
重新啟用:systemctl restart supervisord.service
停止:systemctl stop supervisord.service

--

--

Jerry Chen
Jerry Chen

No responses yet