认识
官网:
文档:http://supervisord.org/introduction.html
仓库:
简而言之,Supervisor,其是个进程管理工具,类似与 init 或 systemd 进程,但是并不是用来替代它们的。
组成
命令程序 and 配置文件
/etc/supervisord.conf https://supervisord.org/configuration.html
性质
1)避免编写复杂的 rc.d 脚本来管理服务,简化服务进程的管理工作;
2)重新启动崩溃的进程;
3)能够精准获取子进程状态,而不在依靠 Pidfile(不准确);
4)简化进程管理、提供网页界面;
4)进程可以分区并设置权重,以批量管理;
构建
依赖环境
Supervisor is intended to work on Python 3 version 3.4 or later and on Python 2 version 2.7.
注意事项
如果从发行版的仓库中安装,那么安装的 Supervisor 版本会落后于官方版本。比如 CentOS 6.5 仓库中只包含 Supervisor 2.1 版本。
如果从发行版安装 Supervisor 是为了自带的服务管理脚本,那大可不必:
GitHub/Supervisor/initscripts
How to automatically start supervisord on Linux (Ubuntu)
Supervisor 2.1 on CentOS 6.5
Supervisor/Installing a Distribution Package
yum install supervisor-2.1 service supervisord start chkconfig supervisord on
应用
在 CentOS 6.x 中,我们会使用 Supervisor 管理进程,避免编写服务管理脚本。
在 CentOS 7.x 中,我们使用 systemd 管理。除了配置简单,我们并没有觉得 Superviosr 比 systemd 功能强大且可靠。
在 CentOS 6.5 中,管理 MyCat 进程:在开机时自动启动;在崩溃时重新启动;
场景 | 自定义 restart/stop 命令
根据 https://github.com/Supervisor/supervisor/issues/147 描述,其并不具备该特性,其通过 SINGNAL 来控制进程退出。
参考