supervisor备忘

JhonSmith

旨在快速配置supervisor

常见问题

  1. 如何不重启supervisor的情况重新读取配置

    supervisorctl reload
    
  2. 如何不让程序随supervisor自动启动

    在conf中添加autostart=false

  3. 多进程如何同时关闭子进程

    在conf中添加stopasgroup=true

下载supervisor

pip install supervisor

创建配置文件

[supervisord]
logfile = /home/john.wang/tmp/supervisord.log
logfile_maxbytes = 50MB
logfile_backups=10
loglevel = info
pidfile = /tmp/supervisord.pid
nodaemon = false
minfds = 1024
minprocs = 200
umask = 022
user = john.wang
identifier = supervisor
directory = /tmp
nocleanup = true
childlogdir = /home/john.wang/tmp
strip_ansi = false

[inet_http_server]
port=127.0.0.1:9001

[unix_http_server]
file=/home/john.wang/tmp/supervisor.sock

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

[supervisorctl]
serverurl = unix:///home/john.wang/tmp/supervisor.sock
username = john.wang
password = none
prompt = mysupervisor

[program:test]
command=echo 123000                                 #命令
directory=/home/john.wang/workspace/                #工作路径
redirect_stderr=true                                #输出流判定
stdout_logfile=/home/john.wang/logs/sp/test.log     #日志文件

启动

supervisord -c /etc/supervisord.conf

管理

supervisorctl Actions

Print a list of available actions

help <action>
Print help for <action>

add <name> [...]
Activates any updates in config for process/group

remove <name> [...]
Removes process/group from active config

update
Reload config and then add and remove as necessary (restarts programs)

clear <name>
Clear a process’ log files.

clear <name> <name>
Clear multiple process’ log files

clear all
Clear all process’ log files

fg <process>
Connect to a process in foreground mode Press Ctrl+C to exit foreground

pid
Get the PID of supervisord.

pid <name>
Get the PID of a single child process by name.

pid all
Get the PID of every child process, one per line.

reread
Reload the daemon’s configuration files, without add/remove (no restarts)

restart <name>
Restart a process Note: restart does not reread config files. For that, see reread and update.

restart <gname>:*
Restart all processes in a group Note: restart does not reread config files. For that, see reread and update.

restart <name> <name>
Restart multiple processes or groups Note: restart does not reread config files. For that, see reread and update.

restart all
Restart all processes Note: restart does not reread config files. For that, see reread and update.

signal
No help on signal

start <name>
Start a process

start <gname>:*
Start all processes in a group

start <name> <name>
Start multiple processes or groups

start all
Start all processes

status
Get all process status info.

status <name>
Get status on a single process by name.

status <name> <name>
Get status on multiple named processes.

stop <name>
Stop a process

stop <gname>:*
Stop all processes in a group

stop <name> <name>
Stop multiple processes or groups

stop all
Stop all processes

tail [-f] <name> [stdout|stderr] (default stdout)
Output the last part of process logs Ex: tail -f <name> Continuous tail of named process stdout Ctrl-C to exit. tail -100 <name> last 100 bytes of process stdout tail <name> stderr last 1600 bytes of process stderr

阅读 1.6k

Hard-boiled Wonderland
简单的记录

这个人很懒, 什么也留不下.

45 声望
6 粉丝
0 条评论

这个人很懒, 什么也留不下.

45 声望
6 粉丝
文章目录
宣传栏