supervisor守护进程

安装supervisor

# ubuntu
apt-get install -y supervisor
# centos
yum install -y supervisor
# alpha
apk add supervisor

# 使用pip
pip install supervisor

# easy_install
easy_install supervisor

# 生成默认配置文件
echo_supervisord_conf > /etc/supervisor/supervisord.conf

# 修改/etc/supervisor/supervisord.conf
[include]
files = /etc/supervisor/conf.d/*.conf

子进程配置

# /etc/supervisor/conf.d/php.conf
[program: php]
command=php-fpm -y /user/local/etc/php/etc/fpm.confp; 被监控的进程路径
priority=1 ; 数字越高,优先级越高 默认值999
numprocs=1 ; 启动几个进程 默认值1
autostart=true ; 随着supervisord的启动而启动
startsecs=10 ; 启动10秒后没有异常退出,就表示进程正常启动了,默认为1秒
autorestart=true ; 程序退出后自动重启, 可选值:[unexpected,true,false],默认为unexpected,表示进程意外杀死后才重启
startretries=10 ; 启动失败时的最多重试次数 默认是3
exitcodes=0 ; 正常退出代码
stopsignal=KILL ; 用来杀死进程的信号
stopwaitsecs=10 ; 发送SIGKILL前的等待时间
redirect_stderr=true ; 重定向stderr到stdout

常用命令

supervisorctl status        //查看所有进程的状态
supervisorctl stop php-fpm       //停止php-fpm  
supervisorctl start php-fpm       //启动php-fpm  
supervisorctl restart php-fpm    //重启php-fpm  
supervisorctl restart all       //重启所有进程
supervisorctl update        //配置文件修改后使用该命令加载新的配置
supervisorctl reload        //重新启动配置中的所有程序
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值