一.supervisor 简介
- supervisord
It is responsible for starting child programs at its own invocation, responding to commands from clients, restarting crashed or exited subprocesseses, logging its subprocess stdout and stderr output, and generating and handling “events” corresponding to points in subprocess lifetimes.
- supervisorctl
supervisor提供的一个客户端,It provides a shell-like interface to the features provided by supervisord. From supervisorctl, a user can connect to different supervisord processes (one at a time), get status on the subprocesses controlled by, stop and start subprocesses of, and get lists of running processes of a supervisord.
- web server
提供的一个在浏览器里可以打开的http访问的管理窗口,A (sparse) web user interface with functionality comparable to supervisorctl may be accessed via a browser if you start supervisord against an internet socket. Visit the server URL (e.g. http://localhost:9001/) to view and control process status through the web interface after activating the configuration file’s [inet_http_server] section.
- [unix_http_server] ;UNIX socket 文件,supervisorctl 会使用
- [inet_http_server] ;HTTP服务器,提供web管理界面
- [supervisord] ;日志文件,默认是 $CWD/supervisord.log
- [supervisorctl] ;通过UNIX socket连接supervisord,包含一些设置与supervisorctl交互的shell命令
- [include] 管理子程序的配置文件路径
2.supervisor管理的子程序的配置文件xxx.ini,一般路径在/etc/supervisor/config.d/
此文件以 [program:xx(program name)] 开头,xx是supervisor要监控的子程序的名字,
四.supervisor 命令
1.supervisord的启动 ;要supervisor监控子程序,必须先把supervisord起来
supervisord -c /etc/supervisor/supervisord.conf
2.supervisorctl ;路径/usr/bin/supervisorctl
- supervisorctl status ;查看所有进程状态
- supervisorctl reload ;重启配置文件里的所有程序
- supervisorctl update ;重载配置文件的改动,并重启相应的进程
- supervisorctl start proc1 ;启动程序proc1
- supervisorctl start all ;启动所有程序
- supervisorctl pid ;查看supervisord 进程ID
直接输入supervisorctl
进入supervisorctl的shell交互界面,此时上面的命令不带supervisorctl可直接使用。
更详细介绍,请参照supervisor官网:http://supervisord.org/