以战养战。通过做项目的形式去学习。更多的POC的形式去把思路DEMO化。
分类: LINUX
2015-11-09 22:21:50
Supervisor是一款Linux下的进程管理软件。最主要的两个功能是:
Supervisor是基于python开发的。安装Supervisor前,需要先安装python。Supervisor可以通过pip或者easy_install安装。
通过pip安装
pip install supervisor
通过easy_install安装
easy_install supervisor
Supervisor没有默认配置文件,需要手工执行命令生成配置文件:
启动Supervisor:
supervisord -c /etc/supervisord.conf
停止Supervisor(子进程也会被停止)
supervisorctl shutdown
查看Supervisor是否已经启动:
[root@aaa blog.cheyo.net]# ps -ef | grep supervisor | grep -v grep root 1170 1 0 18:57 ? 00:00:00 /usr/bin/python /usr/bin/supervisord [root@aaa blog.cheyo.net]#
查看业务进程是否已经被拉起:
[root@aaa blog.cheyo.net]# supervisorctl status check12306 RUNNING pid 1230, uptime 0:04:39 [root@aaa blog.cheyo.net]#
Supervisor可通过维护命令supervisorctl管理或通过web管理界面管理。维护命令supervisorctl有两种用法。一种是命令式,一种是交互式。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# 查询各进程运行状态 supervisorctl status # 启、停、重启业务进程,check12306为进程名,即[program:check12306]里配置的值
supervisorctl start check12306
supervisorctl stop check12306
supervisorctl restart check12306 #重启所有属于名为groupworker这个分组的进程
supervisorctl start groupworker
supervisorctl stop groupworker
supervisorctl restart groupworker #启、停、重启全部进程(不会载入最新的配置文件)
supervisorctl start all
supervisorctl stop all
supervisorctl restart all #重新加载配置文件.停止原有进程并按新的配置启动所有进程
supervisorctl reload #根据最新的配置文件,启动新配置或有改动的进程,配置没有改动的进程不会受影响而重启。
supervisorctl update #注意:显示用stop停止掉的进程,用reload或者update都不会自动重启
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@aaa blog.cheyo.net]# supervisorctl
check12306 RUNNING pid 1256, uptime 0:01:47
supervisor> stop check12306
check12306: stopped
supervisor> start check12306
check12306: started
supervisor> status
check12306 RUNNING pid 1258, uptime 0:00:04
supervisor> restart check12306
check12306: stopped
check12306: started
supervisor> status
check12306 RUNNING pid 1259, uptime 0:00:02
supervisor>
|
点击(此处)折叠或打开