supervisor 简单搭建
pip install supervisor
1.安装 supervisor 与 supervisor依赖 这里不做解释
2.创建配置文件
执行这个命令 echo_supervisord_conf > /etc/supervisord.conf 注意路径
#可以自定义加载 进程 到 配置文件中
执行 vim /etc/supervisord.conf
修改文件末尾。 就会 动态加载/etc/supervisor/supervisord.d/ 下的所有.conf 进程文件
[include]
files = /etc/supervisor/supervisord.d/*.conf
3. 进程文件配置
[program:demo]
command=python -u /home/demo/demo.py ; 如果没有log 使用 python -u
user=root
autostart=true
autorestart=true
startsecs=3
stderr_logfile=/var/log/supervisor/supervisord_error.log ;
stdout_logfile=/var/log/supervisor/supervisord_out.log ;
command 命令的路径最好不要写在etc/ supervisor
启动 主conf 文件
命令:supervisord -c /etc/supervisord/supervisord.conf
报错:
Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord.
For help, use /usr/bin/supervisord -h
运行这俩命令
unlink /var/run/supervisor.sock
unlink /tmp/supervisor.sock
重启
supervisorctl reload
报错
error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib64/python2.7/socket.py line: 224
执行生成 sock命令supervisord -c /etc/supervisord/supervisord.conf
每次 修改 配置文件需要 supervisor update
修改了主 conf 文件 需要从新启动 /etc/supervisor/supervisord.conf
后台进程太多 批量结束进程命令
ps -ef |grep supervisor | awk '{print "kill -9 "$2}' | sh
如果 主配置文件 报 /tmp/错误
自食其力 百度一大推
这个文章也可以:
https://www.cnblogs.com/cq90/p/9538048.html
# 如果执行supervisorctl 报错 需要把conf 配置文件 [supervisorctl] ip:prod 解开