Supervisor 、Supervisord-Monitor 的web统一管理安装、配置、使用

Supervisor: A Process Control System

说明:[http://supervisord.org/]Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems.

Supervisor使用python开发的一个c/s服务,linux下进程管理系统、监听、重启、停止进程。Server supervisord,supervisorctl作为客户端管理进程。


一、 安装

1、yum 安装: yum install supervisor

2、easy_install 安装:wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py -O |python && easy_install supervisor

3、salt stack安装:

Supervisor 、Supervisord-Monitor 的web统一管理安装、配置、使用


init.sls

{% if grains['osmajorrelease'] == "6" %}

supervisor_install:

cmd.run:

- name: yum install python python-meld3 -y && rpm -Uvh http://****/supervisor-3.0-1.gf.el6.noarch.rpm

{% elif grains['osmajorrelease'] == "7" %}

supervisor:

pkg:

- installed

{% endif %}

/etc/supervisord.d/:

file.directory:

- makedirs: True

- mode: 755

/etc/supervisord.conf:

file.managed:

- source: salt://supervisord/files/supervisord.conf

- backup: minion

- template: jinja

/etc/supervisord.d/templet.ini:

file.managed:

- source: salt://supervisord/files/templet.ini

supervisord:

service.running:

- watch:

- file: /etc/supervisord.conf

- reload: True

- enable: True


salt安装:salt “*” state.sls supervisord

supervisor安装完成后,会生成supervisord(supervisor守护进程)、supervisorctl(客户端)、echo_supervisord_conf(生成配置文件),


二、 配置文件

cat /etc/supervisord.conf

[unix_http_server]

file=/var/tmp/supervisor.sock ;socket 文件,supervisorctl 会使用

[inet_http_server]

port=ip:9001 ;Web管理后台运行的IP和端口,建议监听内网ip

[supervisord]

logfile=/var/log/supervisor/supervisord.log

logfile_maxbytes=50MB ;日志文件大小,超出会rotate,默认 50MB,如果设成0,表示不限制大小

logfile_backups=10 ;日志文件保留备份数量默认10,设为0表示不备份

loglevel=info

pidfile=/var/run/supervisord.pid

nodaemon=false

minfds=1024

minprocs=200

[rpcinterface:supervisor]

supervisor.rpcinterface_factory

[supervisorctl]

serverurl=http://ip:9001

[include]

files = supervisord.d/*.ini

cat /etc/supervisord.d/templet.ini (进程模版,来自saltstack)

;[program:templet]

;command=/www/webcode/templet/bin/catalina.sh run

;user=appuser

;autostart=true

;autorestart=true

;startretries=3

;stopsignal=QUIT

;stopasgroup=true

;killasgroup=true

;stdout_logfile=/www/webcode/templet/logs/catalina.out

;redirect_stderr=true

;environment=JAVA_HOME=/opt/java

;stdout_capture_maxbytes=1024MB

;stdout_events_enabled=true

具体见:http://supervisord.org/configuration.html


三、 启动supervisor:

supervisord -c /etc/supervisord.conf

systemctl start supervisord

/etc/init.d/supervisord start

四、 supervisorctl使用

通过supervisorctl对进程进行管理:

supervisorctl help

Supervisor 、Supervisord-Monitor 的web统一管理安装、配置、使用

五、 Web管理:地址见配置文件

http://localip:9001,可以进行进程的重启,日志查看等操作

Supervisor 、Supervisord-Monitor 的web统一管理安装、配置、使用

六、 多主机统一管理:

官方推荐:http://supervisord.org/plugins.html

cesiWeb-based dashboard written in Python.

Django-DashvisorWeb-based dashboard written in Python. Requires Django 1.3 or 1.4.

NodervisorWeb-based dashboard written in Node.js.

Supervisord-MonitorWeb-based dashboard written in PHP.

SupervisorUIAnother Web-based dashboard written in PHP.

supervisorclusterctlCommand line tool for controlling multiple Supervisor instances using Ansible.

suponoffWeb-based dashboard written in Python 3. Requires Django 1.7 or later.

SupvisorsDesigned for distributed applications, written in Python 2.7. Includes an extended XML-RPC API and a Web-based dashboard.

目前我们自己使用Supervisord-Monitor,可以通过dash来管理不同服务器上Supervisord程,重启、停止、日志看等。具体截如下:

Supervisor 、Supervisord-Monitor 的web统一管理安装、配置、使用

上一篇:MyCms 自媒体 CMS 系统 v2.8,支持织梦数据导入


下一篇:轻松实现织梦网站数据迁移到新站点