supervisor学习笔记

1. What-是什么?

supervisor是linux系统下的一个进程管理工具, 主要使用Python语言实现

supervisor配置文件supervisord.conf参数解析

$CWD表示运行supervisord程序的目录。

; supervisor config file

[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; socket file mode (default 0700)

[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards(通配符).  The filenames are
; interpreted as(interpreted as: 把...解释为) relative to this file.  Included files *cannot*
; include files themselves.
; 包含其他配置文件
[include]
files = /etc/supervisor/conf.d/*.conf

参考文档

Supervisor安装与配置(Linux/Unix进程管理工具) 4、配置文件参数说明

2. How-怎么用?

2.1 supervisor常用命令

# 通过-c选项指定supervisor具体加载的配置文件
supervisord -c /data/supervisor/supervisord.conf

2.2 bash终端中supervisor常用命令

sudo supervisorctl reload					# 重载,在修改supervisor配置文件后需要进行重载

supervisorctl status
supervisorctl stop tomcat
supervisorctl start tomcat
supervisorctl restart tomcat
supervisorctl reread
supervisorctl update

2.3 web管理界面

出于安全考虑,supervisor默认配置是没有开启web管理界面的;
如果想要使用supervisor web管理界面,需要修改supervisord.conf配置文件打开http访权限,添加配置如下:

[inet_http_server]					; inet (TCP) server disabled by default
port=0.0.0.0:9001					; (ip_address:port specifier, *:port for all iface)
username=root						; (default is no username (open server)) 
password=123456						; (default is no password (oper server))

打开浏览器,访问 localhost:9001,输入用户名/密码,显示类似如下界面:
supervisor学习笔记_第1张图片

相关文档

Supervisor安装与配置(Linux/Unix进程管理工具)
supervisor 管理进程简明教程
Supervisor使用教程

你可能感兴趣的:(other)