supervisord.conf配置详解

这里仅作关键配置详细描述,全量配置详细描述参考官网配置

[unix_http_server]          ; 如果配置文件没有[unix_http_server]部分,则不会启动UNIX域套接字HTTP服务器
file=/tmp/supervisor.sock   ; 一个指向UNIX域套接字的路径,supervisor将在该套接字上侦听HTTP/XML-RPC请求
;chmod=0700                 ; 在启动时将UNIX域套接字的UNIX权限模式位更改为此值 (默认 0700)
;chown=nobody:nogroup       ; 将套接字文件的用户和组更改为此值,可以是UNIX用户名(例如chrism)或由冒号分隔的UNIX用户名和组(例如chrism:wheel)(默认 启动用户名和组)
;username=user              ; 对此 HTTP 服务器进行身份验证所需的用户名 
;password=123               ; 验证此 HTTP 服务器所需的密码 

;[inet_http_server]         ; 默认情况下不启用 inet HTTP 服务器。 inet HTTP服务器是通过取消注释[inet_http_server]部分启用 
;port=127.0.0.1:9001        ; 侦听的TCP主机端口值,supervisor将在其上侦听HTTP/XML-RPC请求
;username=user              ; 对此 HTTP 服务器进行身份验证所需的用户名 
;password=123               ; 对此 HTTP 服务器进行身份验证所需的密码 

[supervisord]
logfile=/tmp/supervisord.log ; supervisord进程的活动日志的路径 (默认 $CWD/supervisord.log)
logfile_maxbytes=500MB       ; 活动日志文件在轮换之前可能消耗的最大字节数,将此值设置为0以指示无限的日志大小(默认 50MB) 
logfile_backups=20           ; 由于活动日志文件轮换而保留的备份数量,如果设置为 0,则不会保留任何备份(默认 10loglevel=info                ; 日志级别(默认 info)其他级别包括: debug,warn,trace
pidfile=/tmp/supervisord.pid ; supervisord保存其pid文件的位置 
nodaemon=false               ; 如果为true,supervisord将在前台启动而不是守护进程 
silent=false                 ; 如果为true且未守护,日志将不会被定向到标准输出stdout 
minfds=65535                 ; 在supervisord成功启动之前必须可用的最小文件描述符数(默认 1024minprocs=1000                ; 在supervisord成功启动之前必须可用的最小进程描述符数(默认 200;umask=022                   ; supervisord进程的umask(默认 022) 
;user=supervisord            ; 指示supervisord将用户切换到此UNIX用户帐户启动,只有以root用户启动supervisord才能切换用户 
;identifier=supervisor       ; 此主管进程的标识符字符串,由 RPC 接口使用(默认 'supervisor';directory=/tmp              ; 当supervisord守护进程时,切换到这个目录 
;nocleanup=true              ; 防止supervisord在启动时清除任何现有的AUTO子日志文件,通常用于调试(默认 false) 
;childlogdir=/tmp            ; 用于AUTO子日志文件的目录(默认 Python的tempfile.gettempdir()的值) 
;environment=KEY="value"     ; KEY="val",KEY2="val2"形式的键/值对列表,将放置在所有子进程的环境中,这不会改变supervisord本身的环境 
;strip_ansi=false            ; 从子日志文件中去除所有 ANSI 转义序列(默认 false) 

; The rpcinterface:supervisor 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:x] sections.

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


[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; 用于访问supervisord服务器的URL,例如http://localhost:9001,对于 UNIX 域套接字,请使用unix:///absolute/path/to/file.sock(默认 http://localhost:9001) 
;username=chris              ; 传递给supervisord服务器以用于身份验证的用户名 
;password=123                ; 传递给supervisord服务器以用于身份验证的密码 
;prompt=mysupervisor         ; 用作supervisorctl提示的字符串 (默认 "supervisor")
;history_file=~/.sc_history  ; 用作readline持久历史文件的路径(默认 无) 


;[program:theprogramname]      ; 配置文件必须包含一个或多个program段,以便supervisord知道它应该启动和控制哪些程序
;command=/bin/cat              ; 该程序启动时将运行的命令(命令可以是绝对的或相对的) 
;process_name=%(program_name)s ; 用于组成此进程的主管进程名称 (默认 %(program_name)s)
;numprocs=1                    ; Supervisor将启动与numprocs命名的该程序的多个实例(默认1),当此配置大于1时,process_name表达式中必须包含%(process_num)s 
;directory=/tmp                ; 一个文件路径,代表一个目录, 在执行子进程之前,supervisord应该临时 chdir到该目录
;umask=022                     ; 表示进程的 umask 的八进制数(例如 002、022)(默认 none) 
;priority=999                  ; 程序在启动和关闭顺序中的相对优先级,较低的优先级表示程序在启动时以及在各种客户端中使用聚合命令(例如“全部启动”/“全部停止”)时首先启动并最后关闭(默认999)
;autostart=true                ; 如果为 true,则该程序将在启动supervisord时自动启动(默认 true) 
;startsecs=1                   ; 启动后程序需要保持运行以认为启动成功(将进程从STARTING状态移动到RUNNING状态)的总秒数(默认 1;startretries=3                ; 在放弃进程并将进程置于FATAL状态之前尝试启动程序时,supervisord将允许的串行失败尝试次数(默认 3;autorestart=unexpected        ; 如果一个进程在处于RUNNING状态时退出,supervisord是否应该自动重新启动它(默认 unexpected)
;exitcodes=0                   ; 与autorestart一起使用的此程序的“预期”退出代码列表(默认 0;stopsignal=TERM               ; 请求停止时用于终止程序的信号。这可以是 TERM、HUP、INT、QUIT、KILL、USR1 或 USR2 中的任何一个(默认 TERM;stopwaitsecs=10               ; 在程序发送停止信号后,等待操作系统将 SIGCHLD 返回给supervisord的秒数,超过将尝试用SIGKILL杀死它(默认 10;stopasgroup=false             ; 如果为true,该标志会导致supervisor向整个进程组发送停止信号并暗示killasgroup(默认 false) 
;killasgroup=false             ; 如果为true,则当诉诸于向程序发送SIGKILL以终止它时,将其发送到其整个进程组,同时照顾其子进程,例如对于使用multiprocessing的Python 程序很有用 
;user=chrism                   ; 指示supervisord使用此 UNIX 用户帐户作为运行程序的帐户。如果supervisord以 root 用户身份运行,则只能切换 用户。如果supervisord 不能切换到指定的用户,程序将不会启动 
;redirect_stderr=true          ; 如果为 true,则将进程的 stderr 输出发送回 其 stdout 文件描述符上的supervisord(在 UNIX shell 术语中,这相当于执行/the/program 2>&1)(默认 false) 
;stdout_logfile=/a/path        ; 将进程 stdout 输出放在此文件中(如果 redirect_stderr 为真,也将 stderr 输出放在此文件中)(默认 AUTO) 
;stdout_logfile_maxbytes=200MB ; stdout_logfile在轮换之前可能消耗的最大字节数,将此值设置为 0 以指示无限的日志大小(默认 50MB) 
;stdout_logfile_backups=10     ; stdout_logfile备份保持周围从工艺标准输出日志文件旋转而产生的数量,如果设置为 0,则不会保留任何备份 (默认 10;stdout_capture_maxbytes=0     ; 当进程处于“stdout 捕获模式”时写入捕获 FIFO 的最大字节数(默认 0;stdout_events_enabled=false   ; 如果为 true,则在进程写入其 stdout 文件描述符时将发出 PROCESS_LOG_STDOUT 事件。仅当文件描述符在接收数据时未处于捕获模式时才会发出事件(默认 0;stdout_syslog=false           ; 如果为 true,stdout 将与进程名称一起定向到 syslog 
;stderr_logfile=/a/path        ; 除非redirect_stderr为真,否则将进程stderr 输出放在此文件中(默认 AUTO)
;stderr_logfile_maxbytes=1MB   ; stderr_logfile 的日志文件轮换之前的最大字节数 (默认 50M)
;stderr_logfile_backups=10     ; 由进程 stderr 日志文件轮换产生的要保留的备份数(默认 10;stderr_capture_maxbytes=1MB   ; 当进程处于“stderr 捕获模式”时写入捕获 FIFO 的最大字节数(默认 0;stderr_events_enabled=false   ; 如果为 true,则在进程写入其 stderr 文件描述符时将发出 PROCESS_LOG_STDERR 事件。仅当文件描述符在接收数据时未处于捕获模式时才会发出事件(默认 false)
;stderr_syslog=false           ; 如果为 true,stderr 将与进程名称一起定向到 syslog
;environment=A="1",B="2"       ; KEY="val",KEY2="val2"形式的键/值对列表,将放置在子进程的环境中
;serverurl=AUTO                ; 在环境中传递给子进程进程的 URL 作为SUPERVISOR_SERVER_URL(请参阅supervisor.childutils)以允许子进程 轻松与内部 HTTP 服务器通信 

; The sample eventlistener section below shows all possible eventlistener
; subsection values.  Create one or more 'real' eventlistener: sections to be
; able to handle event notifications sent by supervisord.

;[eventlistener:theeventlistenername]
;command=/bin/eventlistener    ; 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)
;events=EVENT                  ; event notif. types to subscribe to (req'd)
;buffer_size=10                ; event buffer queue size (default 10)
;directory=/tmp                ; directory to cwd to before exec (def no cwd)
;umask=022                     ; umask for process (default None)
;priority=-1                   ; the relative start priority (default -1)
;autostart=true                ; start at supervisord start (default: true)
;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)
;startretries=3                ; max # of serial start failures when starting (default 3)
;autorestart=unexpected        ; autorestart if exited after running (def: unexpected)
;exitcodes=0                   ; 'expected' exit codes used with autorestart (default 0)
;stopsignal=QUIT               ; signal used to kill process (default TERM)
;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
;killasgroup=false             ; SIGKILL the UNIX process group (def false)
;user=chrism                   ; setuid to this UNIX account to run the program
;redirect_stderr=false         ; redirect_stderr=true is not allowed for eventlisteners
;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10     ; # of stdout logfile backups (0 means none, default 10)
;stdout_events_enabled=false   ; emit events on stdout writes (default false)
;stdout_syslog=false           ; send stdout to syslog with process name (default false)
;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10     ; # of stderr logfile backups (0 means none, default 10)
;stderr_events_enabled=false   ; emit events on stderr writes (default false)
;stderr_syslog=false           ; send stderr to syslog with process name (default false)
;environment=A="1",B="2"       ; process environment additions
;serverurl=AUTO                ; override serverurl computation (childutils)

; The sample group section below shows all possible group values.  Create one
; or more 'real' group: sections to create "heterogeneous" process groups.

;[group:thegroupname]
;programs=progname1,progname2  ; 以逗号分隔的程序名称列表。列出的程序成为该组的成员 
;priority=999                  ; 类似于分配给组的[program:x]优先级值的优先级编号 

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.
; 如果你需要指定多个目录,可以通过使用英文冒号 : 或分号 ; 来分隔这些目录
[include]
files = /usr/local/env/supervisor/conf/*.ini

以下提供精简版常用配置示例
[unix_http_server]
file=/var/run/supervisor/supervisor.sock
chmod=755
chown= apps

[supervisord]
logfile=/ext/logs/supervisor/supervisord.log
logfile_maxbytes=200MB
logfile_backups=30
loglevel=info
pidfile=/var/run/supervisor/supervisord.pid
nodaemon=false
minfds=65535
minprocs=10240

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

[supervisorctl]
serverurl=unix:///var/run/supervisor/supervisor.sock

[include]
files = /usr/local/javaserver/supervisord/*.ini

/usr/local/javaserver/supervisord/目录下配置示例如下

[program:cms]
command=java -server -Xms1024m -Xmn512m -Xmx1024m -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -jar -Dspring.profiles.active=prod /usr/local/javaserver/spring/cms/cms.jar 
user=apps
startsecs=5
autorestart=true
priority=999
stdout_logfile=/ext/logs/supervisor/%(program_name)s/%(program_name)s.log
stderr_logfile=/ext/logs/supervisor/%(program_name)s/%(program_name)s.err
stdout_logfile_maxbytes=200MB
stderr_logfile_maxbytes=200MB
stdout_logfile_backups=20
stderr_logfile_backups=20
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值