supervisor 守护多个进程_Supervisor 管理后台守护进程

安装

pip install supervisor

启动

supervisord

supervisord -c /etc/supervisord.conf

supervisord 的配置文件默认位于 /etc/supervisord.conf,;后面为注释

关闭服务

supervisorctl stop all 先关闭supervisor启动脚本,之后再关闭supervisord服务

kill pid

配置

supervisord 配置 program 项的路径下:/etc/supervisor/conf.d/,然后 program 的配置文件命名规则推荐:app_name.conf

常用命令

查看正在守候的进程【常用】

supervisorctl status

重新加载配置

supervisorctl reread

更新新的配置到supervisord【常用】

supervisorctl update

重新启动配置中的所有程序

supervisorctl reload

启动某个进程

supervisorctl start program_name

停止某一进程

pervisorctl stop program_name

重启某一进程

supervisorctl restart program_name

踩过的坑

执行supervisorctl status报错【error: , [Errno 101] Network is unreachable: file: /usr/local/python/lib/python2.7/socket.py line: 575】

问题原因:找不到supervisord.conf文件

解决方法:

1)进入到supervisord目录再执行命令;

2)supervisorctl status -c /etc/supervisord.conf

supervisor monitor工具

安装

git clone https://github.com/mlazarov/supervisord-monitor.git

进入到application中,将默认的配置文件重命名

cd /root/supervisord-monitor/application/config

cp supervisor.php.example supervisor.php

打开该配置文件,所有需要连接的服务器都是在这个文件中进行设置的

vim supervisor.php

按照如下格式,输入需要连接的服务器的ip地址和用户名密码即可

$config['supervisor_servers'] = array(

'127.0.0.1' => array(

'url' => 'http://127.0.0.1/RPC2',

'port' => '9001',

'username' => 'user',

'password' => '123'

),

);

给网站加密码

通过htpasswd对该网页进行加密处理,需要登录才能进入网页

1)安装httpd-tools:yum -y install httpd-tools

2)然后在指定位置创建密码文件

htpasswd -c /etc/nginx/htpasswd admin

新增用户/修改密码:htpasswd /etc/nginx/htpasswd admin

删除用户:htpasswd -D /etc/nginx/htpasswd admin

3)在nginx配置中进行配置

vim /etc/nginx/nginx.conf

location / {

auth_basic "nginx basic http test for localhost";

auth_basic_user_file htpasswd;

autoindex on;

try_files $uri $uri/ /index.php;

}

4)重启nginx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值