在linux里用pip install supervisor,配置文件都在**/usr/local/python3/bin**里,安裝時會有黃色字提醒的:
WARNING: The scripts echo_supervisord_conf, pidproxy, supervisorctl and supervisord are installed in '/usr/local/python3/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
1
2
所以當我們在自己項目里用vim配置好自己寫的supervisor.conf 時,執行
supervisord -c supervisor.conf 時,會報錯:無法找到supervisord這個包。
解決辦法:
cd /usr/local/python3/bin,里面有echo_supervisord_conf, pidproxy, supervisorctl and supervisord 。
我們只要
cp supervisord /usr/bin/
1
把supervisord復制到/usr/bin/目錄下即可
再次執行,親測可以成功。
/etc/supervisord.conf內容:
[supervisord] logfile = /tmp/supervisord.log logfile_maxbytes = 50MB logfile_backups=10 loglevel = info pidfile = /tmp/supervisord.pid nodaemon = false minfds = 1024 minprocs = 200 umask = 022 identifier = supervisor directory = /tmp nocleanup = true childlogdir = /tmp strip_ansi = false [supervisorctl] serverurl = unix:///tmp/supervisor.sock prompt = mysupervisor [program:MyFlask] # 啟動命令入口 command=/usr/bin/uwsgi /opt/onlinewww/MyFlask/uwsgi.ini directory=/opt/onlinewww/MyFlask #運行命令的用戶名 user=root autostart=true #跟隨Supervisor一起啟動 autorestart=true # 掛掉之后自動重啟 #日志地址 #stdout_logfile=/var/www/app/logs/uwsgi_supervisor.log
啟動:supervisord -c /etc/supervisord.conf
