linux 安装 supervisor

本文介绍了supervisor的简单搭建过程,包括安装及依赖、创建配置文件、进程文件配置等步骤。还提及启动主conf文件时可能遇到的报错及解决办法,如端口占用、socket文件问题等,同时给出修改配置文件后的操作及批量结束进程命令。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 解开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值