supervisor安装配置与使用(2)

;command=/bin/echo;   supervisor启动时将要开启的进程。相对或绝对路径均可。若是相对路径则会从supervisord的$PATH变中查找。命令可带参数。
;priority=999                 指明进程启动和关闭的顺序。低优先级表明进程启动时较先启动关闭时较后关闭。高优先级表明进程启动时启动时较后启动关闭时较先关闭。
;autostart=true               是否随supervisord启动而启动
;autorestart=true             进程意外退出后是否自动重启
;startsecs=10                 进程持续运行多久才认为是启动成功
;startretries=3               重启失败的连续重试次数
;exitcodes=0,2               若autostart设置为unexpected且监控的进程并非因为supervisord停止而退出,那么如果进程的退出码不在exitcode列表中supervisord将重启进程
;stopsignal=QUIT             杀进程的信号
;stopwaitsecs=10             向进程发出stopsignal后等待OS向supervisord返回SIGCHILD 的时间。若超时则supervisord将使用SIGKILL杀进程

一个Rabbitmq项目中生产者和消费者进程使用supervisor监控的配置情况:(配置中的其他部分略)

[program:worker_for_summary]
command=/home/op1/scripts/rabbitmqclient/worker_for_summary.py
priority=1
log_stderr=true            ; if true, log program stderr (def false)

[program:worker_for_detail_all]
command=/home/op1/scripts/rabbitmqclient/worker_for_detail_all.py
priority=1
log_stderr=true            ; if true, log program stderr (def false)

[program:worker_for_detail_recent_list]
command=/home/op1/scripts/rabbitmqclient/worker_for_detail_recent_list.py
priority=1
log_stderr=true            ; if true, log program stderr (def false)

[program:worker_for_detail_recent_sset]
command=/home/op1/scripts/rabbitmqclient/worker_for_detail_recent_sset.py
priority=1
log_stderr=true            ; if true, log program stderr (def false)

[program:publisher_for_summary]
command=/home/op1/scripts/rabbitmqclient/publisher_for_summary.py
priority=999
log_stderr=true            ; if true, log program stderr (def false)

[program:publisher_for_summary_nt]
command=/home/op1/scripts/rabbitmqclient/publisher_for_summary_nt.py
priority=999
log_stderr=true            ; if true, log program stderr (def false)

[program:publisher_for_detail]
command=/home/op1/scripts/rabbitmqclient/publisher_for_detail.py
priority=999
log_stderr=true            ; if true, log program stderr (def false)

[program:publisher_for_detail_nt]
command=/home/op1/scripts/rabbitmqclient/publisher_for_detail_nt.py
priority=999
log_stderr=true            ; if true, log program stderr (def false)

配置完成后启动supervisord'

sudo /etc/init.d/supervisord start

可以看到配置的各个进程在后台运行了起来。
停掉某个进程后supervisor会马上重启该进程

停止supervisor

sudo /etc/init.d/supervisord stop

可以看到配置的各个进程都停止运行了。 

可以通过supervisorctl查看管理监控的进程情况:

[op1@SVR1631HP360 ~]$ sudo supervisorctl
publisher_for_detail RUNNING    pid 27557, uptime 0:00:45
publisher_for_detail_nt RUNNING    pid 27567, uptime 0:00:45
publisher_for_summary RUNNING    pid 27566, uptime 0:00:45
publisher_for_summary_nt RUNNING    pid 27568, uptime 0:00:45
worker_for_detail_all RUNNING    pid 27581, uptime 0:00:45
worker_for_detail_recent RUNNING    pid 27582, uptime 0:00:45
worker_for_summary RUNNING    pid 27559, uptime 0:00:45

#可通过help了解命令的更多用法
supervisor> help

Documented commands (type help <topic>):
========================================
EOF    exit  maintail  quit    restart  start  stop
clear  help  open      reload  shutdown  status  tail

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/250a9381f388191ced245816b234bf9d.html