Open pupuk opened 4 years ago
supervisorctl Actions
help
Print a list of available actions
help <action>
Print help for add <name> [...]
Activates any updates in config for process/group
remove <name> [...]
Removes process/group from active config
update
Reload config and add/remove as necessary, and will restart affected programs
update all
Reload config and add/remove as necessary, and will restart affected programs
update <gname> [...]
Update specific groups, and will restart affected programs
clear <name>
Clear a process’ log files.
clear <name> <name>
Clear multiple process’ log files
clear all
Clear all process’ log files
fg <process>
Connect to a process in foreground mode Press Ctrl+C to exit foreground
pid
Get the PID of supervisord.
pid <name>
Get the PID of a single child process by name.
pid all
Get the PID of every child process, one per line.
reload
Restarts the remote supervisord
reread
Reload the daemon’s configuration files, without add/remove (no restarts)
restart <name>
Restart a process Note: restart does not reread config files. For that, see reread and update.
restart <gname>:*
Restart all processes in a group Note: restart does not reread config files. For that, see reread and update.
restart <name> <name>
Restart multiple processes or groups Note: restart does not reread config files. For that, see reread and update.
restart all
Restart all processes Note: restart does not reread config files. For that, see reread and update.
signal
No help on signal
start <name>
Start a process
start <gname>:*
Start all processes in a group
start <name> <name>
Start multiple processes or groups
start all
Start all processes
status
Get all process status info.
status <name>
Get status on a single process by name.
status <name> <name>
Get status on multiple named processes.
stop <name>
Stop a process
stop <gname>:*
Stop all processes in a group
stop <name> <name>
Stop multiple processes or groups
stop all
Stop all processes
tail [-f] <name> [stdout|stderr] (default stdout)
Output the last part of process logs Ex: tail -f
简介
正如官网上所说:Supervisor: A Process Control System,Supervisor是一个进程管理器,可以把要监控的进程作为supervisord的子进程来运行,因为supervisord是被监控进程的父进程,所以子进程的退出,崩溃关闭,父进程可以来拿相关的信息。 所以supervisor可以实现,对管理进程的自动重启,状态日志管理,比如可以对某个shell命令或者golang编译后的二进制包,实现后台运行,自动重启,保证程序一定程度的高可用。
官网:http://supervisord.org/ Github:https://github.com/Supervisor/supervisor
安装配置
supervisor是python写的,现在可以兼容python2, python3,所以可是使用python的特色管理工具pip安装,
pip install supervisor
也可以使用yum管理工具安装:
yum install -y supervisor
安装就不赘述,参见http://supervisord.org/installing.html 就行,安装完成后,会生成三个二进制文件:
echo_supervisord_conf
是用来生成缺省配置文件的,如果安装好supervisor以后,没有发现/etc/supervisord.conf
文件,则可以用echo_supervisord_conf
程序来创建一个配置文件,例如:echo_supervisord_conf > /etc/supervisord.conf
,此操作需要root权限;supervisorctl是supervisor的命令行终端,类似于mysql,redis-cli;
supervisord是supervisor的服务程序,supervisor最重要的工作是supervisord干的;
如果/etc/supervisord.conf文件里面有
则可以像nginx以上,为每个单独的进程配制一个文件,放到
/etc/supervisord.d/
目录下,不全部写在一起,方便管理。 配置文件参考/etc/supervisord.conf就行,里面有例子,最简单的如下:自身管理和管理别人
supervisor是靠Linux提供的systemd来管理自己的,可是实现随Linux开机启动等;
systemctl start[stop][reload][restart][status][enable][disable] supervisord.service
supervisor根据配置文件来管理别的进程,通过使用 supervisorctl终端,可以很方便管理要监控的进程:
如果不会某个命令(action),可以使用 hlep 来查看相应的说明,例如:
更详尽的 systemctl终端命令的使用可以详见下面的评论
其它
supervisor可以对进程编组,进行组管理,另外,还有信号,事件这些特色功能,这些都是值得我们深入学习的地方;
另外:其它的进程管理工具也有一些, golang版本的supervisor,https://github.com/ochinchina/supervisord nodejs生态的pm2,https://github.com/Unitech/pm2