|
发表于 2024-12-31 15:07:20
|
查看: 67 |
回复: 0
1.问题背景
在使用supervisor+gunicorn+flask进行服务部署时,出现如下报错:
- entered FATAL state, too many start retries too quickly
复制代码 看到上述报错,就很懵逼,我这才启动怎么会说已经重试很多次了?
2.解决方法
通过查看生成的supervisor.conf:
- ; Sample supervisor config file.
- ;
- ; For more information on the config file, please see:
- ; http://supervisord.org/configuration.html
- ;
- ; Notes:
- ; - Shell expansion ("~" or "$HOME") is not supported. Environment
- ; variables can be expanded using this syntax: "%(ENV_HOME)s".
- ; - Quotes around values are not supported, except in the case of
- ; the environment= options as shown below.
- ; - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
- ; - Command will be truncated if it looks like a config file comment, e.g.
- ; "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ".
- ;
- ; Warning:
- ; Paths throughout this example file use /tmp because it is available on most
- ; systems. You will likely need to change these to locations more appropriate
- ; for your system. Some systems periodically delete older files in /tmp.
- ; Notably, if the socket file defined in the [unix_http_server] section below
- ; is deleted, supervisorctl will be unable to connect to supervisord.
-
-
- [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 服务器所需的密码
-
-
- ; Security Warning:
- ; The inet HTTP server is not enabled by default. The inet HTTP server is
- ; enabled by uncommenting the [inet_http_server] section below. The inet
- ; HTTP server is intended for use within a trusted environment only. It
- ; should only be bound to localhost or only accessible from within an
- ; isolated, trusted network. The inet HTTP server does not support any
- ; form of encryption. The inet HTTP server does not use authentication
- ; by default (see the username= and password= options to add authentication).
- ; Never expose the inet HTTP server to the public internet.
-
- ;[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,则不会保留任何备份(默认 10)
- loglevel=info ; 日志级别(默认 info)其他级别包括: debug,warn,trace
- pidfile=/tmp/supervisord.pid ; supervisord保存其pid文件的位置
- nodaemon=false ; 如果为true,supervisord将在前台启动而不是守护进程
- silent=false ; 如果为true且未守护,日志将不会被定向到标准输出stdout
- minfds=65535 ; 在supervisord成功启动之前必须可用的最小文件描述符数(默认 1024)
- minprocs=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
-
- ; The supervisorctl section configures how supervisorctl will connect to
- ; supervisord. configure it match the settings in either the unix_http_server
- ; or inet_http_server section.
-
-
- [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持久历史文件的路径(默认 无)
-
-
- ; The sample program section below shows all possible program subsection values.
- ; Create one or more 'real' program: sections to be able to control them under
- ; supervisor.
-
- ;[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
复制代码 因为配置文件的默认用户是root,而容器限制了启动的用户。比如我这边限制了应用的启动用户为ocpuser,故检查配置文件中的用户是否是ocpuser,若不是则改为ocpuser:
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
|