程序员

Supervisord安装配置

2019-02-01  本文已影响9人  404d67ac8c12

官方文档: http://www.supervisord.org
官方下载: https://pypi.python.org/pypi/supervisor

安装方法
  1. 使用 root 用户将安装包解压后执行安装:
$ python setup.py install
$ chmod 750  $(which supervisorctl)  $(which supervisord)
  1. 初始化工作目录:
$ mkdir -p  /opt/supervisor/{bin,conf,log}
$ mkdir -p  /opt/supervisor/conf/conf.d
$ chown -R root:root  /opt/supervisor
$ chmod -R 755  /opt/supervisor
  1. 创建配置模板参考文件(非必须,参考用的):
$ echo_supervisord_conf  >  /opt/supervisor/conf/supervisord.conf.sample
  1. Supervisor配置文件
# /opt/supervisor/conf/supervisord.conf

[unix_http_server]
file=/tmp/supervisor.sock
chmod=0777

[supervisord]
logfile=/opt/supervisor/log/supervisord.log
logfile_maxbytes=10MB
logfile_backups=5
loglevel=info
pidfile=/tmp/supervisord.pid
nodaemon=false
minfds=1024
minprocs=200

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock

[include]
files = /opt/supervisor/conf/conf.d/*.conf
  1. 新建应用配置文件
# /opt/supervisor/conf/conf.d/your_app_name.conf

[program:your_app_name]
command=/opt/supervisor/bin/your_app_name_start.py
user=root
stdout_logfile=/opt/supervisor/log/your_app_name.log
stderr_logfile=/opt/supervisor/log/your_app_name.err
stdout_logfile_maxbytes=10MB
stderr_logfile_maxbytes=10MB
stdout_logfile_backups=5
stderr_logfile_backups=5
autostart=true
startretries=3
autorestart=unexpected
stopsignal=TERM
stopwaitsecs=8
environment=HOME="/root"
  1. 启动
    使用root用户启动supervisord:
$ /usr/local/bin/supervisord  -c /opt/supervisor/conf/supervisord.conf

加入开机自启动,在/etc/rc.local中添加下面一行:

/usr/local/bin/supervisord  -c /opt/supervisor/conf/supervisord.conf
  1. 使用
查看帮助
# supervisorctl help
查看当前应用状态
# supervisorctl status
启动应用
# supervisorctl start your_app_name
停止应用
# supervisorctl stop your_app_name
新增应用配置文件后重新加载配置文件
# supervisorctl update
上一篇下一篇

猜你喜欢

热点阅读