supervisord : supervisor的服务器端部分,启动supervisor就是运行这个命令


需求:./open_search 这个进程是运行go的一个服务。我们要求这个服务能在意外停止后自动重启。


yum install python-setuptools

easy_install supervisor




; Sample supervisor config file.


; For more information on the config file, please see:



; Note: shell expansion (”~” or “$HOME”) is not supported. Environment

; variables can be expanded using this syntax: “%(ENV_HOME)s”.


file=/tmp/supervisor.sock ; (the path to the socket file)

;chmod=0700 ; socket file mode (default 0700)

;chown=nobody:nogroup ; socket file uid:gid owner

;username=user ; (default is no username (open server))

;password=123 ; (default is no password (open server))

;[inet_http_server] ; inet (TCP) server disabled by default

;port= ; (ip_address:port specifier, *:port for all iface)

;username=user ; (default is no username (open server))

;password=123 ; (default is no password (open server))


logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)

logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)

logfile_backups=10 ; (num of main logfile rotation backups;default 10)

loglevel=info ; (log level;default info; others: debug,warn,trace)

pidfile=/tmp/ ; (supervisord pidfile;default


; the below section must remain in the config file for RPC

; (supervisorctl/web interface) to work, additional interfaces may be

; added by defining them in separate rpcinterface: sections


supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface


serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket

;serverurl= ; use an http:// url to specify an inet socket

;username=chris ; should be same as http_username if set

;password=123 ; should be same as http_password if set

;prompt=mysupervisor ; cmd line prompt (default “supervisor”)

;history_file=~/.sc_history ; use readline history if available

; The below sample program section shows all possible program subsection values,

; create one or more ‘real’ program: sections to be able to control them under

; supervisor.


;command=/bin/cat ; the program (relative uses PATH, can take args)

;process_name=%(program_name)s ; process_name expr (default %(program_name)s)

;numprocs=1 ; number of processes copies to start (def 1)

;directory=/tmp ; directory to cwd to before exec (def no cwd)

;umask=022 ; umask for process (default None)

;priority=999 ; the relative start priority (default 999)

;autostart=true ; start at supervisord start (default: true)

;autorestart=unexpected ; whether/when to restart (default: unexpected)

;startsecs=1 ; number of secs prog must stay running (def. 1)

;startretries=3 ; max # of serial start failures (default 3)

;exitcodes=0,2 ; ‘expected’ exit codes for process (default 0,2)

;stopsignal=QUIT ; signal used to kill process (default TERM)

;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)



;files = relative/directory/*.ini


echo_supervisord_conf > /etc/supervisord.conf




command=/home/s/www/fukun/gopath/src/open_search/open_search ;需要执行的命令

directory=/home/s/www/fukun/gopath/src/open_search/ ; directory to cwd to before exec (def no cwd)

autostart=true ; start at supervisord start (default: true)

autorestart=true ; whether/when to restart (default: unexpected)

startsecs=3 ; number of secs prog must stay running (def. 1)

redirect_stderr=true ; redirect proc stderr to stdout (default false) 错误输出重定向

stdout_logfile=/tmp/open_search_gorun.log ; stdout log path, NONE for none; default AUTO, log输出



supervisord //启动supervisor

supervisorctl //打开命令行

[root@vm14211 ~]# supervisorctl

redis RUNNING pid 24068, uptime 3:41:55

ctl中: help //查看命令

ctl中: status //查看状态


如果修改了 /etc/supervisord.conf ,,需要执行 supervisorctl reload 来重新加载配置文件,否则会感觉没有生效,折腾到抓狂。。。