找回密码
立即注册
搜索
发新帖

10

积分

0

好友

2

主题
发表于 2024-12-31 15:07:20 | 查看: 67| 回复: 0
1.问题背景

在使用supervisor+gunicorn+flask进行服务部署时,出现如下报错:
  1. entered FATAL state, too many start retries too quickly
复制代码
看到上述报错,就很懵逼,我这才启动怎么会说已经重试很多次了?

2.解决方法

通过查看生成的supervisor.conf:
  1. ; Sample supervisor config file.
  2. ;
  3. ; For more information on the config file, please see:
  4. ; http://supervisord.org/configuration.html
  5. ;
  6. ; Notes:
  7. ;  - Shell expansion ("~" or "$HOME") is not supported.  Environment
  8. ;    variables can be expanded using this syntax: "%(ENV_HOME)s".
  9. ;  - Quotes around values are not supported, except in the case of
  10. ;    the environment= options as shown below.
  11. ;  - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
  12. ;  - Command will be truncated if it looks like a config file comment, e.g.
  13. ;    "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ".
  14. ;
  15. ; Warning:
  16. ;  Paths throughout this example file use /tmp because it is available on most
  17. ;  systems.  You will likely need to change these to locations more appropriate
  18. ;  for your system.  Some systems periodically delete older files in /tmp.
  19. ;  Notably, if the socket file defined in the [unix_http_server] section below
  20. ;  is deleted, supervisorctl will be unable to connect to supervisord.


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


  27. ; Security Warning:
  28. ;  The inet HTTP server is not enabled by default.  The inet HTTP server is
  29. ;  enabled by uncommenting the [inet_http_server] section below.  The inet
  30. ;  HTTP server is intended for use within a trusted environment only.  It
  31. ;  should only be bound to localhost or only accessible from within an
  32. ;  isolated, trusted network.  The inet HTTP server does not support any
  33. ;  form of encryption.  The inet HTTP server does not use authentication
  34. ;  by default (see the username= and password= options to add authentication).
  35. ;  Never expose the inet HTTP server to the public internet.

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

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

  58. ; The rpcinterface:supervisor section must remain in the config file for
  59. ; RPC (supervisorctl/web interface) to work.  Additional interfaces may be
  60. ; added by defining them in separate [rpcinterface:x] sections.

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

  63. ; The supervisorctl section configures how supervisorctl will connect to
  64. ; supervisord.  configure it match the settings in either the unix_http_server
  65. ; or inet_http_server section.


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


  72. ; The sample program section below shows all possible program subsection values.
  73. ; Create one or more 'real' program: sections to be able to control them under
  74. ; supervisor.

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

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

  110. ;[eventlistener:theeventlistenername]
  111. ;command=/bin/eventlistener    ; the program (relative uses PATH, can take args)
  112. ;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
  113. ;numprocs=1                    ; number of processes copies to start (def 1)
  114. ;events=EVENT                  ; event notif. types to subscribe to (req'd)
  115. ;buffer_size=10                ; event buffer queue size (default 10)
  116. ;directory=/tmp                ; directory to cwd to before exec (def no cwd)
  117. ;umask=022                     ; umask for process (default None)
  118. ;priority=-1                   ; the relative start priority (default -1)
  119. ;autostart=true                ; start at supervisord start (default: true)
  120. ;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)
  121. ;startretries=3                ; max # of serial start failures when starting (default 3)
  122. ;autorestart=unexpected        ; autorestart if exited after running (def: unexpected)
  123. ;exitcodes=0                   ; 'expected' exit codes used with autorestart (default 0)
  124. ;stopsignal=QUIT               ; signal used to kill process (default TERM)
  125. ;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
  126. ;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
  127. ;killasgroup=false             ; SIGKILL the UNIX process group (def false)
  128. ;user=chrism                   ; setuid to this UNIX account to run the program
  129. ;redirect_stderr=false         ; redirect_stderr=true is not allowed for eventlisteners
  130. ;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
  131. ;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
  132. ;stdout_logfile_backups=10     ; # of stdout logfile backups (0 means none, default 10)
  133. ;stdout_events_enabled=false   ; emit events on stdout writes (default false)
  134. ;stdout_syslog=false           ; send stdout to syslog with process name (default false)
  135. ;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
  136. ;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
  137. ;stderr_logfile_backups=10     ; # of stderr logfile backups (0 means none, default 10)
  138. ;stderr_events_enabled=false   ; emit events on stderr writes (default false)
  139. ;stderr_syslog=false           ; send stderr to syslog with process name (default false)
  140. ;environment=A="1",B="2"       ; process environment additions
  141. ;serverurl=AUTO                ; override serverurl computation (childutils)
  142. ; The sample group section below shows all possible group values.  Create one
  143. ; or more 'real' group: sections to create "heterogeneous" process groups.
  144. ;[group:thegroupname]
  145. ;programs=progname1,progname2  ; 以逗号分隔的程序名称列表。列出的程序成为该组的成员
  146. ;priority=999                  ; 类似于分配给组的[program:x]优先级值的优先级编号
  147. ; The [include] section can just contain the "files" setting.  This
  148. ; setting can list multiple files (separated by whitespace or
  149. ; newlines).  It can also contain wildcards.  The filenames are
  150. ; interpreted as relative to this file.  Included files *cannot*
  151. ; include files themselves.
  152. [include]
  153. files = /usr/local/env/supervisor/conf/*.ini
复制代码
因为配置文件的默认用户是root,而容器限制了启动的用户。比如我这边限制了应用的启动用户为ocpuser,故检查配置文件中的用户是否是ocpuser,若不是则改为ocpuser:


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

您需要登录后才可以回帖 登录 | 立即注册

Archiver|手机版|小黑屋|AAWW论坛

GMT+8, 2025-2-5 19:38 , Processed in 0.088002 second(s), 29 queries .

Powered by aaww.net

管理员:admin@aaww.net

快速回复 返回顶部 返回列表