一、安装软件
sudo pip_python install supervisor
sudo echo_supervisord_conf > /etc/supervisord.conf # 会报错 permission denied: /etc/supervisord.conf,可以使用下面的语句
sudo su - root -c "echo_supervisord_conf > /etc/supervisord.conf"
二、更改主配置文件
1、sudo vim /etc/supervisord.conf
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
[include]
files = /etc/supervisord.d/*.ini ;此路径更改为自己配置的路径及配置文件后缀名
这里要注意 unix_http_server 跟 supervisorctl中的 sock 文件目录要一致
然后创建目录
sudo su - root -c "mkdir -p /etc/supervisord.d"
三、新增项目配置
[program:somejob]
command=/usr/bin/python /home/lzz/temp/super/somejob.py
directroy=/home/lzz/temp/super/
autostart=true
autorestart=true
startretries=3
user=www
stdout_logfile=/home/lzz/temp/super/%(program_name)s.log
stderr_logfile=/home/lzz/temp/super/%(program_name)s.log
四、命令
1、启动命令
sudo /usr/local/bin/supervisord -c /etc/supervisord.conf
2、重载和更新命令
supervisorctl reload
supervisorctl restart all