supervisor 部署文档

supervisor 部署文档

supervisor 需要Python支持,如果不用系统的supervisor,单独安装python

python 安装

#依赖
yum install python-urllib3 openssl openssl-devel sqlite  sqlite-devel bzip2 bzip2-devel libzdb libzdb-devel -y
#下载安装
wget http://og4a7z6nl.bkt.clouddn.com/Python-2.7.12.tgz
wget http://og4a7z6nl.bkt.clouddn.com/get-pip.py
tar -xf Python-2.7.12.tgz
cd Python-2.7.12
./configure --prefix=/home/nick/python
make && make install
#安装pip
/home/nick/python/bin/python get-pip.py

supervisor 安装

/home/nick/python/bin/pip install supervisor

mkdir /home/nick/suprvisor 
cd /home/nick/supervisor && mkdir bin log conf
cp /home/nick/python/bin/supervisor* bin/
/home/nick/python/bin/echo_supervisord_conf > conf/

#修改supervisor 用户权限
sed -i "/chown/a\chown=nick:nick         ; socket file uid:gid owner" /home/nick/supervisor/conf/supervisord.conf

#操作脚本
echo "/home/nick/python/bin/python /home/nick/supervisor/bin/supervisorctl -c /home/nick/supervisor/conf/supervisord.conf $1 $2" >/home/nick/superctl
#给执行权限
chmod +x /home/nick/superctl

supervisor 启动

#以root 启动
/home/nick/python/bin/python /home/nick/supervisor/bin/supervisord -c /home/nick/supervisor/conf/supervisord.conf

# 开机自启动
echo "/home/nick/python/bin/python /home/nick/supervisor/bin/supervisord -c /home/nick/supervisor/conf/supervisord.conf" >> /etc/rc.local

配置

#一个简单的配置
[program:nginx]
command=/home/nick/nginx/sbin/nginx -c /home/nick/nginx/conf/nginx.conf ;启动命令
diretory=/home/nick/nginx ;程序启动的目录
autostart = true    ;supervisor启动也自动启动
user=root           ;启动的用户

操作

#一些常用操作
start app   启动一个服务
stop app    停止一个服务
restart app 重启一个服务
update      更新supervisor 只影响修改的服务和新服务
reload      重载supervisor 所有服务都将受影响
status      显示服务状态

posted on 2017-01-09 18:07  扶朕起来,朕还能送  阅读(326)  评论(0编辑  收藏  举报

导航