Centos 7 pip3安装 supervisor

发布时间 2023-04-09 18:58:36作者: 苦逼yw

1、安装supervisor

pip3installsupervisor

2、新建文件夹

mkdir/etc/supervisord.d

3、生成supervisor.conf配置

echo_supervisord_conf>/etc/supervisord.conf

4、启动supervisor

/usr/local/python3/bin/supervisord-c/etc/supervisord.conf

5、例子:配置supervisor管理nginx进程

vim/etc/supervisord.conf

去掉注释

[include]files=/etc/supervisord.d/*.conf

配置supervisor管理nginx的配置文件

vim/etc/supervisord.d/nginx_test.conf[program:nginx]command=/usr/sbin/nginxstdout_logfile=/tmp/nginx.logstderr_logfile=/tmp/nginx_err.logautostart=trueautorestart=truestartsecs=10stopwaitsecs=50     #这里最好配置 
priority=1 

6、supervisor不能管理daemon进程,nginx 是daemon进程,如果要管理,需要在nginx.conf配置文件的http标签外增加 daemon off; 此处只是测试适用

# 修改nginx配置
[root@auto super]# vim /etc/nginx/nginx.confusernginx;worker_processes1;daemonoff;events{worker_connections1024;}http{.......

7、重启nginx,supervisor

supervisorctlreload

其他命令

supervisorctl #查看所有子进程的状态
supervisorctl reload #重启  修改了supervisord.conf ,需要执行来重新加载配置文件
supervisorctl status #查看所有进程的状态
supervisorctl stop demo #停止
supervisorctl start demo #启动
supervisorctl restart demo #重启
supervisorctl update #配置文件修改或新增后可以使用该命令加载新的进程

8、web界面管理supervisor进程

修改配置文件,然后重启

vim/etc/supervisor.conf
#去掉注释,下面是修改部分

[inet_http_server] ; inet (TCP) server disabled by default
port=192.168.10.66:9001;ip_address:portspecifier,*:portfor all iface
username=user;default isnousername(openserver)password=123;default isnopassword(openserver)

 

 

 

 

 

 
mkdir/etc/主管