supervisor使用


  1. 安裝`sudo apt-get install supervisor``
  2. `echo_supervisord_conf 查看默認(rèn)配置項(xiàng)
  3. 配置說明

一份配置文件至少需要一個 [program:x] 部分的配置,來告訴 supervisord 需要管理那個進(jìn)程。

[program:x]語法中的 x 表示 program name,會在客戶端(supervisorctl或 web 界面)顯示,在 supervisorctl 中通過這個值來對程序進(jìn)行start、restart、stop等操作。

#程序名稱,在 supervisorctl 中通過這個值來對程序進(jìn)行一系列的操作
[program:laravel-worker]

process_name=%(program_name)s_%(process_num)02d
#啟動程序的命令,項(xiàng)目文件地址
command=php /home/forge/app.com/artisan queue:work

#啟動程序的命令;
autostart=true

#在supervisord啟動的時候也自動啟動;
autorestart=true

#開啟進(jìn)程使用哪個用戶和組啟動(這里forge啟動時指定了nobody用戶所以就不用再指定了);
user=forge

#對同一配置開啟3個線程。
numprocs=3

#把 stderr 重定向到 stdout,默認(rèn) false
redirect_stderr=true

#標(biāo)準(zhǔn)日志輸出;
stdout_logfile=/home/forge/app.com/worker.log

#錯誤日志輸出;
stderr_logfile=/home/forge/app.com/err.log

#標(biāo)準(zhǔn)日志文件大小,默認(rèn)50MB;
stdout_logfile_maxbytes = 20MB

#標(biāo)準(zhǔn)日志文件備份數(shù);
stdout_logfile_backups = 20
  1. 常用命令
  • service supervisor start /etc/init.d/supervisor start 啟動
  • ps -ef| grep supervisor 查看啟動狀態(tài)
  • supervisorctl status 查看進(jìn)程啟動狀態(tài)
  • supervisorctl stop|start|restart tomcat
  • 或者進(jìn)入客戶端 supervisorctl
  1. 參考文獻(xiàn):
    [Docs]: http://supervisord.org/index.html
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容