0
点赞
收藏
分享

微信扫一扫

Web方式管理后台进程:Supervisor


简介

Supervisor是一个可以监控多个进程的C/S系统,不支持Windows,基于Python语言开发。

安装

使用PIP安装

pip install supervisor

配置

配置文件位置和格式

supervisor默认从以下目录开始搜索配置文件:

  1. ​$CWD/supervisord.conf​
  2. ​$CWD/etc/supervisord.conf​
  3. ​/etc/supervisord.conf​
  4. ​/etc/supervisor/supervisord.conf (since Supervisor 3.3.0)​
  5. ​../etc/supervisord.conf (Relative to the executable)​
  6. ​../supervisord.conf (Relative to the executable)​

也可以使用命令supervisord和supervisorctl的​​-c​​参数来指定配置文件。

配置文件格式是windows ini文件格式,就是可以用ConfigParser模块解析的格式。

添加要监控的子程序

[program:example]
command=/usr/bin/example --loglevel=%(ENV_LOGLEVEL)s

​%(ENV_LOGLEVEL)​​表示日志等级。

更多例子:

Apache

[program:apache2]
command=/path/to/httpd -c "ErrorLog /dev/stdout"
redirect_stderr=true

ZEO

[program:zeo]
command=/path/to/runzeo
priority=1

[program:zope1]
command=/path/to/instance/home/bin/runzope
priority=2
redirect_stderr=true

[program:zope2]
command=/path/to/another/instance/home/bin/runzope
priority=2
redirect_stderr=true

Postgres 8.X

[program:postgres]
command=/path/to/postmaster
; we use the "fast" shutdown signal SIGINT
stopsignal=INT
redirect_stderr=true

OpenLDAP slapd

[program:slapd]
command=/path/to/slapd -f /path/to/slapd.conf -h ldap://0.0.0.0:8888
redirect_stderr=true

配置HTTP server

[unix_http_server]
file = /tmp/supervisor.sock
chmod = 0777
chown= nobody:nogroup
username = user
password = 123

[inet_http_server]
port = 127.0.0.1:9001
username = user
password = 123

运行

启动supervisord服务

supervisord

打开子程序

supervisorctl start all

​​更多运行参数​​

打开web浏览器

访问:

http://127.0.0.1:9001

ip可以指定为本地公网ip或​​*​

参考

  • ​​官网​​


举报

相关推荐

0 条评论