用 supervisord 管理进程

经常会碰到要写一些守护进程,常用做法放入后台:nohup php taskDispatchSlave.php &一个两个这样还可以管理,多个就麻烦了。那天再找gearman的例子,发现一个 supervisord 的工具,相当好用,这个软件是python写的。supervisor官方地址:http://supervisord.org,官方标语就是:一个进程管理工具。ubuntu: sudo apt-get install supervisorrehl/centos: easy_install supervisor or yum install supervisorps:如果没有 easy_install 命令先安装 sudo yum install python-pip 再执行上面的命令我这里用的 centos:? easy_install supervisor 安装好后。

输入 echo_supervisord_conf > ?/etc/supervisord.conf

在最后一行加入[program:myworker]command=/usr/local/php/bin/php /root/as/cli/taskDispatchSlave.phpprocess_name=%(program_name)s_%(process_num)02d;修改numprocs即可同时开启多个worker进程numprocs_start=3numprocs=3autostart=trueautorestart=true;user=gearmandstopsignal=KILLstdout_logfile=/tmp/xxx_catch_slave.log保存

/etc/supervisord.conf 跟多配置解释参考 http://supervisord.org/configuration.html#unix-http-server-section-settings

找到?inet_http_server 去掉注释[inet_http_server] ; inet (TCP) server disabled by default#port=127.0.0.1:9001 ; (ip_address:port specifier, *:port for all iface)port=192.168.6.36:9080username=xxx ; (default is no username (open server))password=xxx999 ; (default is no password (open server))

启动 supervisordcmd:supervisordWEB管理

supervisor web mangage

cli 管理

输入?supervisorctl

supervisorctl>start?myworker

supervisorctl>stop?myworker

supervisorctl>restart?myworker

如果改了配置,加入新的进程,要进行 reload 一次

supervisorctl 命令列更多看help

用 supervisord 管理进程

相关文章:

你感兴趣的文章:

标签云: