简单小结
上手非常快, 日志输出会是运维中的一大帮手, 自动重启是防止服务异常中断的第一重保障.非常适合服务不断增多的系统, 管理上非常nice!
安装
启动
supervisord -c <conf_path>
|
进入控制台
supervisorctl -c <conf_path> -u <user> -p <password>
|
常用命令
以下命令均在控制台执行, 也可以直接在命令行执行, 如supervisorctl -c <conf_path> -u <user> -p <password> start all
启动、停止和重启进程:
启动所有进程:
启动特定进程:
停止所有进程:
停止特定进程:
重启所有进程:
重启特定进程:
查看进程状态:
重新加载配置文件:
查看日志:
配置示例
[rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[unix_http_server] file=/run/server.sock chmod=0700 chown=root:root
[supervisorctl] serverurl=unix:///run/server.sock
[supervisord] user=root logfile=/tmp/server.log logfile_maxbytes=96MB logfile_backups=3 loglevel=info pidfile=/run/server.pid directory=/server stopasgroup=true killasgroup=true environment= PATH='/usr/local/miniconda/envs/py/bin', RUN='DEV'
[group:api] programs=api-1,api-2 priority=100
[program:api-1] command=python app autostart=false autorestart=true redirect_stderr=true environment= API_PORT=9000,
[program:api-2] command=python app autostart=false autorestart=true redirect_stderr=true environment= API_PORT=9010, [program:worker] command=celery -A app.worker worker -l info -B -c 10 autostart=false autorestart=true redirect_stderr=true
|
配置文件说明
[rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[unix_http_server] file=/run/supervisor.sock chmod=0700 chown=root:root
[supervisorctl] serverurl=unix:///run/supervisor.sock serverurl=http://127.0.0.1:9001
[inet_http_server] port=127.0.0.1:9001 username=user password=pawd
[supervisord] logfile=/tmp/supervisord.log logfile_maxbytes=50MB logfile_backups=10 loglevel=info pidfile=/tmp/supervisord.pid nodaemon=false minfds=1024 minprocs=200 directory=/root/project environment= PATH='/root/project/bin', ENV='TEST',
[group:g_name] programs=api,worker
[program:api] command=python api autostart=true startsecs=10 autorestart=true startretries=3 user=tomcat priority=999 redirect_stderr=true stdout_logfile_maxbytes=20MB stdout_logfile_backups = 20
stdout_logfile=/tmp/api.log stopasgroup=false killasgroup=false
[include] files = confs/*.conf
|
Supervisor documentation (supervisord.org)