博客 / 詳情

返回

supervisor 指定 python 版本及配置示例

pkg_resources.DistributionNotFound: The 'supervisor==3.4.0' distribution was not found and is required by the application

有時系統安裝了 python3python2,且 python3 為默認版本,安裝啓動 supervisor 時就報錯了。

yum install supervisor

編輯以下3個文件,將開頭的 python 解釋器路徑指定為 2 版本的即可。

vim /usr/bin/echo_supervisord_conf
vim /usr/bin/supervisorctl
vim /usr/bin/supervisord

啓動

systemctl start supervisord.service

示例

/etc/supervisord.d/demoQueue.ini

[program:demo]
directory = /www/wwwroot/demo ;啓動目錄
command = php think queue:work --queue demoQueue --daemon ;啓動命令
autostart = true ;在supervisord啓動的時候也啓動
startsecs = 5 ;啓動5秒後沒有異常退出,就當作已經正常啓動了
autorestart = true ;程序異常退出後自動重啓
startretries = 3 ;啓動失敗自動重試次數,默認是3
user = www ;哪個用户啓動
redirect_stderr = true ;把stderr重定向到stdout,默認false
stdout_logfile_maxbytes = 20MB ;stdout日誌文件大小,默認50MB
stdout_logfile_backups = 7 ;stdout日誌文件備份數
stdout_logfile = /www/wwwroot/supervisor/demo/demoQueue.log ;stdout日誌文件
systemctl restart supervisord.service
supervisorctl star/stop demoQueue
supervisorctl status demoQueue
supervisorctl update #重啓配置文件發生改動的程序
supervisorctl reread #載入新的配置文件
supervisorctl restart #重啓某個應用
supervisorctl reload #重啓 supervisor
user avatar darkgel 頭像 zuiyuesi 頭像
2 位用戶收藏了這個故事!

發佈 評論

Some HTML is okay.