天天看点

Supervisor 进程守护

下载安装

先看下本机是否有 我的本机已经有了。

[[email protected] supervisord.d]# whereis supervisord

supervisord: /usr/bin/supervisord /etc/supervisord.d /etc/supervisord.conf

[[email protected] supervisord.d]# 

yum方式安装

 yum install supervisor

python方式 

wget https://pypi.python.org/packages/source/s/supervisor/supervisor-3.1.3.tar.gz
tar zxvf supervisor-3.1.3.tar.gz
cd supervisor-3.1.3
python setup.py install      

Supervisor 进程守护
 vim /etc/supervisord.conf 

编辑配置文件 修改两个地方就可以使用了

Supervisor 进程守护
Supervisor 进程守护

 启动服务

supervisord -c /usr/supervisor/supervisord.conf

 到这一步,就可以通过 http://ip:9001/ 查看supervisor的web界面了

Supervisor 进程守护

现在配置 要守护的进程cd /etc/supervisord.d/

 cd /etc/supervisord.d/
Supervisor 进程守护
[program:flume]
command=/apps/flume/bin/flume-ng agent --conf /apps/flume/conf --conf-file /apps/flume/conf/agentMain-conf.properties --name a1 -Dflume.root.logger=INFO,console  ; 被监控的进程路径
priority=1                    ; 数字越高,优先级越高
numprocs=1                    ; 启动几个进程
autostart=true                ; 随着supervisord的启动而启动
autorestart=true              ; 自动重启
startretries=10               ; 启动失败时的最多重试次数
exitcodes=0                   ; 正常退出代码
stopsignal=KILL               ; 用来杀死进程的信号
stopwaitsecs=10               ; 发送SIGKILL前的等待时间
redirect_stderr=true          ; 重定向stderr到stdout      

supervisorctl -c /etc/supervisord.conf    重新加载配置

[[email protected] flume]# supervisorctl -c /etc/supervisord.conf  

Server requires authentication

Username:user

Password:

flume                            RUNNING   pid 11446, uptime 0:16:00

supervisor> reload

继续阅读