Linux进程监控服务Supervisor快速入门
Linux进程监控服务Supervisor快速入门
官网地址: http://www.supervisord.org/
准备
1、 系统中需安装Python环境,我本机python为2.6.6
2、 下载安装supervisor所需软件
elementtree
meld3
setuptools
supervisor
安装
以上四个都为python相关插件,分别解压后,进入各自所在目录中,使用python setup.py install
命令安装,其安装顺序依次为:
elementtree、meld3、setuptools、supervisor
⚠️在安装setuptools时需要先执行python bootstrap.py
,然后执行python setup.py install
命令安装
添加配置文件
配置文件 /etc/supervisord.conf
配置内容如下:
[unix_http_server] file = /var/run/supervisor.sock chmod = 0777 chown= root:root [inet_http_server] # Web管理界面设定 port=node03:9001 ;username = admin ;password = yourpassword [supervisorctl] ; 必须和'unix_http_server'里面的设定匹配 serverurl = unix:///var/run/supervisor.sock [supervisord] logfile=/var/log/supervisord/supervisord.log ; (main log file;default $CWD/supervisord.log) logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB) logfile_backups=10 ; (num of main logfile rotation backups;default 10) loglevel=info ; (log level;default info; others: debug,warn,trace) pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) nodaemon=false ; (start in foreground if true;default false) minfds=1024 ; (min. avail startup file descriptors;default 1024) minprocs=200 ; (min. avail process descriptors;default 200) user=root ; (default is current user, required if root) childlogdir=/var/log/supervisord/ ; ('AUTO' child log dir, default $TEMP) [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface ;管理的单个进程的配置,可以添加多个program [program:cat] command=/bin/cat autostart = true startsecs = 5 user = root redirect_stderr = true ; 对这个program的log的配置,上面的logfile_maxbytes是supervisord本身的log配置 stdout_logfile_maxbytes = 20MB stdoiut_logfile_backups = 20 stdout_logfile = /var/log/supervisord/cat.log
启动服务
方式一:
# supervisord
方式二:
# supervisord -c /path/to/supervisord.conf
方式一启动时会自己寻找/etc/supervisord.conf
文件;方式二通过-c
参数指定配置文件所在路径
启动后可以通过Web界面查看服务运行情况,服务地址为:node1:9001
管理服务
使用supervisorctl
命令进行服务管理操作:
[root@node1 zxm]# supervisorctl chatdemon RUNNING pid 47457, uptime 0:07:38 test RUNNING pid 47456, uptime 0:07:38 supervisor> help default commands (type help <topic>): ===================================== add exit open reload restart start tail avail fg pid remove shutdown status update clear maintail quit reread signal stop version supervisor> status cat RUNNING pid 47555, uptime 0:00:08 chatdemon RUNNING pid 47554, uptime 0:00:08 test RUNNING pid 47553, uptime 0:00:08
[include]标签
可以使用[include]标签来指定应用程序配置文件,例如:
[zxm@node1 supervise-programs]# cat /etc/supervisord.conf ... ... [include] files= /home/zxm/works/supervise-programs/cat.conf
/home/zxm/works/supervise-programs/cat.conf
内容如下:
相关推荐
以梦为马不负韶华 2020-10-20
farwang 2020-11-25
星愿心愿 2020-11-24
tianhuak 2020-11-24
zhjn0 2020-11-24
昭君出塞 2020-11-23
bluecarrot 2020-11-23
linuxwcj 2020-10-21
彼岸随笔 2020-10-20
yutou0 2020-10-17
applecarelte 2020-10-16
ourtimes 2020-10-16
waterhorse 2020-09-19
MRFENGG 2020-11-11
rainandtear 2020-10-30
kyssfanhui 2020-10-20
liuhangtiant 2020-10-20