简介
Supervisor 是一个 Client/Server 系统,它允许用户监视和控制类 UNIX (Linux)操作系统上的许多进程。
supervisord
Supervisor 的服务器模块名为 supervisord
。它负责在自己的调用中启动子程序,响应业自客户央的命令,重启崩溃或退出的子进程,记录其子进程 stdout
和 stderr
输出,并生成和处理子进程生命周期中相对应的 事件。
服务器进程使用的配置文件通常位于/etc/supervisord.conf
中。 此配置文件是“ Windows-INI”样式的配置文件。 通过适当的文件系统权限来确保此文件的安全很重要,因为它可能包含未加密的用户名和密码。
supervisorctl
Supervisor 的命令行客户端名为 supervisorctl
。它为 supervisord
的功能提供了类似于shell
的接口。
通过supervisorctl
,用户可以连接到不同的supervisord
进程(一次一个),获取所控制的子进程的状态,停止
和启动
的子进程,以及获取一个supervisord
的正在运行的进程的列表。
命令行客户端通过 UNIX 域套接字或Internet(TCP)套接字与服务器通信。 服务器可以断言客户端的用户应该在允许客户端执行命令之前出示身份验证凭据。 客户端进程通常使用与服务器相同的配置文件,但是其中包含[supervisorctl
]章节的任何配置文件都可以使用。
Web Server
可通过浏览器访问的 Web 服务。访问服务器的URL示例:http://localhost:9001/ 。
XML-RPC Interface
一个 HTTP 服务器,为 web UI 提供了一个 XML-RPC 接口,该接口可用于查询和控制管理程序及其运行的程序。
可以根据此组件提供的接口开发自己的进程监控管理 Web 控制台,或与其它监控平台进行整合。
命令行
- 在 Linux 可以输入
supervisorctl
命令,进入工具命令行模式,再输入指令:status | start | restart | stop [process_name]
直接在 Linux 输入
supervisorctl status | start | restart | stop [process_name]
命令执行操作。更新配置到 supervisord
supervisorctl update
- 所有进程重载配置
supervisorctl reload
查看所有管理的进程
[root@localhost ~]# supervisorctl authHospital RUNNING pid 21304, uptime 20:10:24 authOpen RUNNING pid 21300, uptime 20:10:24 conv_goods RUNNING pid 2204, uptime 0:03:32 [root@localhost ~]# supervisorctl status
启动,重启,状态,停止
[root@localhost ~]# supervisorctl status authHospital RUNNING pid 21304, uptime 20:10:24 authOpen RUNNING pid 21300, uptime 20:10:24 conv_goods RUNNING pid 2204, uptime 0:03:32 # 启动所有进程 [root@localhost ~]# supervisorctl start all # 关闭所有进程 [root@localhost ~]# supervisorctl stop all # 指定进程 [root@localhost ~]# supervisorctl status authOpen authOpen RUNNING pid 21300, uptime 20:15:20
参考资料
注意:本文归作者所有,未经作者允许,不得转载