configuration.rst 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376
  1. Configuration File
  2. ==================
  3. The Supervisor configuration file is conventionally named
  4. :file:`supervisord.conf`. It is used by both :program:`supervisord`
  5. and :program:`supervisorctl`. If either application is started
  6. without the ``-c`` option (the option which is used to tell the
  7. application the configuration filename explicitly), the application
  8. will look for a file named :file:`supervisord.conf` within the
  9. following locations, in the specified order. It will use the first
  10. file it finds.
  11. #. :file:`$CWD/supervisord.conf`
  12. #. :file:`$CWD/etc/supervisord.conf`
  13. #. :file:`/etc/supervisord.conf`
  14. :file:`supervisord.conf` is a Windows-INI-style (Python ConfigParser)
  15. file. It has sections (each denoted by a ``[header]``)and key / value
  16. pairs within the sections. The sections and their allowable values
  17. are described below.
  18. ``[unix_http_server]`` Section Settings
  19. ---------------------------------------
  20. The :file:`supervisord.conf` file contains a section named
  21. ``[unix_http_server]`` under which configuration parameters for an
  22. HTTP server that listens on a UNIX domain socket should be inserted.
  23. If the configuration file has no ``[unix_http_server]`` section, a
  24. UNIX domain socket HTTP server will not be started. The allowable
  25. configuration values are as follows.
  26. ``[unix_http_server]`` Section Values
  27. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  28. ``file``
  29. A path to a UNIX domain socket (e.g. :file:`/tmp/supervisord.sock`)
  30. on which supervisor will listen for HTTP/XML-RPC requests.
  31. :program:`supervisorctl` uses XML-RPC to communicate with
  32. :program:`supervisord` over this port. This option can include the
  33. value ``%(here)s``, which expands to the directory in which the
  34. :program:`supervisord` configuration file was found.
  35. *Default*: None.
  36. *Required*: No.
  37. *Introduced*: 3.0
  38. ``chmod``
  39. Change the UNIX permission mode bits of the UNIX domain socket to
  40. this value at startup.
  41. *Default*: ``0700``
  42. *Required*: No.
  43. *Introduced*: 3.0
  44. ``chown``
  45. Change the user and group of the socket file to this value. May be
  46. a UNIX username (e.g. ``chrism``) or a UNIX username and group
  47. separated by a colon (e.g. ``chrism:wheel``).
  48. *Default*: Use the username and group of the user who starts supervisord.
  49. *Required*: No.
  50. *Introduced*: 3.0
  51. ``username``
  52. The username required for authentication to this HTTP server.
  53. *Default*: No username required.
  54. *Required*: No.
  55. *Introduced*: 3.0
  56. ``password``
  57. The password required for authentication to this HTTP server. This
  58. can be a cleartext password, or can be specified as a SHA-1 hash if
  59. prefixed by the string ``{SHA}``. For example,
  60. ``{SHA}82ab876d1387bfafe46cc1c8a2ef074eae50cb1d`` is the SHA-stored
  61. version of the password "thepassword".
  62. Note that hashed password must be in hex format.
  63. *Default*: No password required.
  64. *Required*: No.
  65. *Introduced*: 3.0
  66. ``[unix_http_server]`` Section Example
  67. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  68. .. code-block:: ini
  69. [unix_http_server]
  70. file = /tmp/supervisor.sock
  71. chmod = 0777
  72. chown= nobody:nogroup
  73. username = user
  74. password = 123
  75. ``[inet_http_server]`` Section Settings
  76. ---------------------------------------
  77. The :file:`supervisord.conf` file contains a section named
  78. ``[inet_http_server]`` under which configuration parameters for an
  79. HTTP server that listens on a TCP (internet) socket should be
  80. inserted. If the configuration file has no ``[inet_http_server]``
  81. section, an inet HTTP server will not be started. The allowable
  82. configuration values are as follows.
  83. ``[inet_http_server]`` Section Values
  84. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  85. ``port``
  86. A TCP host:port value or (e.g. ``127.0.0.1:9001``) on which
  87. supervisor will listen for HTTP/XML-RPC requests.
  88. :program:`supervisorctl` will use XML-RPC to communicate with
  89. :program:`supervisord` over this port. To listen on all interfaces
  90. in the machine, use ``:9001`` or ``*:9001``.
  91. *Default*: No default.
  92. *Required*: Yes.
  93. *Introduced*: 3.0
  94. ``username``
  95. The username required for authentication to this HTTP server.
  96. *Default*: No username required.
  97. *Required*: No.
  98. *Introduced*: 3.0
  99. ``password``
  100. The password required for authentication to this HTTP server. This
  101. can be a cleartext password, or can be specified as a SHA-1 hash if
  102. prefixed by the string ``{SHA}``. For example,
  103. ``{SHA}82ab876d1387bfafe46cc1c8a2ef074eae50cb1d`` is the SHA-stored
  104. version of the password "thepassword".
  105. Note that hashed password must be in hex format.
  106. *Default*: No password required.
  107. *Required*: No.
  108. *Introduced*: 3.0
  109. ``[inet_http_server]`` Section Example
  110. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  111. .. code-block:: ini
  112. [inet_http_server]
  113. port = 127.0.0.1:9001
  114. username = user
  115. password = 123
  116. ``[supervisord]`` Section Settings
  117. ----------------------------------
  118. The :file:`supervisord.conf` file contains a section named
  119. ``[supervisord]`` in which global settings related to the
  120. :program:`supervisord` process should be inserted. These are as
  121. follows.
  122. ``[supervisord]`` Section Values
  123. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  124. ``logfile``
  125. The path to the activity log of the supervisord process. This
  126. option can include the value ``%(here)s``, which expands to the
  127. directory in which the supervisord configuration file was found.
  128. *Default*: :file:`$CWD/supervisord.log`
  129. *Required*: No.
  130. *Introduced*: 3.0
  131. ``logfile_maxbytes``
  132. The maximum number of bytes that may be consumed by the activity log
  133. file before it is rotated (suffix multipliers like "KB", "MB", and
  134. "GB" can be used in the value). Set this value to 0 to indicate an
  135. unlimited log size.
  136. *Default*: 50MB
  137. *Required*: No.
  138. *Introduced*: 3.0
  139. ``logfile_backups``
  140. The number of backups to keep around resulting from activity log
  141. file rotation. If set to 0, no backups will be kept.
  142. *Default*: 10
  143. *Required*: No.
  144. *Introduced*: 3.0
  145. ``loglevel``
  146. The logging level, dictating what is written to the supervisord
  147. activity log. One of ``critical``, ``error``, ``warn``, ``info``,
  148. ``debug``, ``trace``, or ``blather``. Note that at log level
  149. ``debug``, the supervisord log file will record the stderr/stdout
  150. output of its child processes and extended info info about process
  151. state changes, which is useful for debugging a process which isn't
  152. starting properly. See also: :ref:`activity_log_levels`.
  153. *Default*: info
  154. *Required*: No.
  155. *Introduced*: 3.0
  156. ``pidfile``
  157. The location in which supervisord keeps its pid file. This option
  158. can include the value ``%(here)s``, which expands to the directory
  159. in which the supervisord configuration file was found.
  160. *Default*: :file:`$CWD/supervisord.pid`
  161. *Required*: No.
  162. *Introduced*: 3.0
  163. ``umask``
  164. The :term:`umask` of the supervisord process.
  165. *Default*: ``022``
  166. *Required*: No.
  167. *Introduced*: 3.0
  168. ``nodaemon``
  169. If true, supervisord will start in the foreground instead of
  170. daemonizing.
  171. *Default*: false
  172. *Required*: No.
  173. *Introduced*: 3.0
  174. ``minfds``
  175. The minimum number of file descriptors that must be available before
  176. supervisord will start successfully. A call to setrlimit will be made
  177. to attempt to raise the soft and hard limits of the supervisord process to
  178. satisfy ``minfds``. The hard limit may only be raised if supervisord
  179. is run as root. supervisord uses file descriptors liberally, and will
  180. enter a failure mode when one cannot be obtained from the OS, so it's
  181. useful to be able to specify a minimum value to ensure it doesn't run out
  182. of them during execution. This option is particularly useful on Solaris,
  183. which has a low per-process fd limit by default.
  184. *Default*: 1024
  185. *Required*: No.
  186. *Introduced*: 3.0
  187. ``minprocs``
  188. The minimum number of process descriptors that must be available
  189. before supervisord will start successfully. A call to setrlimit will be
  190. made to attempt to raise the soft and hard limits of the supervisord process
  191. to satisfy ``minprocs``. The hard limit may only be raised if supervisord
  192. is run as root. supervisord will enter a failure mode when the OS runs out
  193. of process descriptors, so it's useful to ensure that enough process
  194. descriptors are available upon :program:`supervisord` startup.
  195. *Default*: 200
  196. *Required*: No.
  197. *Introduced*: 3.0
  198. ``nocleanup``
  199. Prevent supervisord from clearing any existing ``AUTO``
  200. chlild log files at startup time. Useful for debugging.
  201. *Default*: false
  202. *Required*: No.
  203. *Introduced*: 3.0
  204. ``childlogdir``
  205. The directory used for ``AUTO`` child log files. This option can
  206. include the value ``%(here)s``, which expands to the directory in
  207. which the :program:`supervisord` configuration file was found.
  208. *Default*: value of Python's :func:`tempfile.get_tempdir`
  209. *Required*: No.
  210. *Introduced*: 3.0
  211. ``user``
  212. If :program:`supervisord` is run as the root user, switch users to
  213. this UNIX user account before doing any meaningful processing. This
  214. value has no effect if :program:`supervisord` is not run as root.
  215. *Default*: do not switch users
  216. *Required*: No.
  217. *Introduced*: 3.0
  218. ``directory``
  219. When :program:`supervisord` daemonizes, switch to this directory.
  220. This option can include the value ``%(here)s``, which expands to the
  221. directory in which the :program:`supervisord` configuration file was
  222. found.
  223. *Default*: do not cd
  224. *Required*: No.
  225. *Introduced*: 3.0
  226. ``strip_ansi``
  227. Strip all ANSI escape sequences from child log files.
  228. *Default*: false
  229. *Required*: No.
  230. *Introduced*: 3.0
  231. ``environment``
  232. A list of key/value pairs in the form ``KEY="val",KEY2="val2"`` that
  233. will be placed in the :program:`supervisord` process' environment
  234. (and as a result in all of its child process' environments). This
  235. option can include the value ``%(here)s``, which expands to the
  236. directory in which the supervisord configuration file was found.
  237. Values containing non-alphanumeric characters should be quoted
  238. (e.g. ``KEY="val:123",KEY2="val,456"``). Otherwise, quoting the
  239. values is optional but recommended. **Note** that subprocesses will
  240. inherit the environment variables of the shell used to start
  241. :program:`supervisord` except for the ones overridden here and within
  242. the program's ``environment`` option. See :ref:`subprocess_environment`.
  243. *Default*: no values
  244. *Required*: No.
  245. *Introduced*: 3.0
  246. ``identifier``
  247. The identifier string for this supervisor process, used by the RPC
  248. interface.
  249. *Default*: supervisor
  250. *Required*: No.
  251. *Introduced*: 3.0
  252. ``[supervisord]`` Section Example
  253. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  254. .. code-block:: ini
  255. [supervisord]
  256. logfile = /tmp/supervisord.log
  257. logfile_maxbytes = 50MB
  258. logfile_backups=10
  259. loglevel = info
  260. pidfile = /tmp/supervisord.pid
  261. nodaemon = false
  262. minfds = 1024
  263. minprocs = 200
  264. umask = 022
  265. user = chrism
  266. identifier = supervisor
  267. directory = /tmp
  268. nocleanup = true
  269. childlogdir = /tmp
  270. strip_ansi = false
  271. environment = KEY1="value1",KEY2="value2"
  272. ``[supervisorctl]`` Section Settings
  273. ------------------------------------
  274. The configuration file may contain settings for the
  275. :program:`supervisorctl` interactive shell program. These options
  276. are listed below.
  277. ``[supervisorctl]`` Section Values
  278. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  279. ``serverurl``
  280. The URL that should be used to access the supervisord server,
  281. e.g. ``http://localhost:9001``. For UNIX domain sockets, use
  282. ``unix:///absolute/path/to/file.sock``.
  283. *Default*: ``http://localhost:9001``
  284. *Required*: No.
  285. *Introduced*: 3.0
  286. ``username``
  287. The username to pass to the supervisord server for use in
  288. authentication. This should be same as ``username`` from the
  289. supervisord server configuration for the port or UNIX domain socket
  290. you're attempting to access.
  291. *Default*: No username
  292. *Required*: No.
  293. *Introduced*: 3.0
  294. ``password``
  295. The password to pass to the supervisord server for use in
  296. authentication. This should be the cleartext version of ``password``
  297. from the supervisord server configuration for the port or UNIX
  298. domain socket you're attempting to access. This value cannot be
  299. passed as a SHA hash. Unlike other passwords specified in this
  300. file, it must be provided in cleartext.
  301. *Default*: No password
  302. *Required*: No.
  303. *Introduced*: 3.0
  304. ``prompt``
  305. String used as supervisorctl prompt.
  306. *Default*: ``supervisor``
  307. *Required*: No.
  308. *Introduced*: 3.0
  309. ``history_file``
  310. A path to use as the ``readline`` persistent history file. If you
  311. enable this feature by choosing a path, your supervisorctl commands
  312. will be kept in the file, and you can use readline (e.g. arrow-up)
  313. to invoke commands you performed in your last supervisorctl session.
  314. *Default*: No file
  315. *Required*: No.
  316. *Introduced*: post-3.0a4 (not including 3.0a4)
  317. ``[supervisorctl]`` Section Example
  318. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  319. .. code-block:: ini
  320. [supervisorctl]
  321. serverurl = unix:///tmp/supervisor.sock
  322. username = chris
  323. password = 123
  324. prompt = mysupervisor
  325. .. _programx_section:
  326. ``[program:x]`` Section Settings
  327. --------------------------------
  328. The configuration file must contain one or more ``program`` sections
  329. in order for supervisord to know which programs it should start and
  330. control. The header value is composite value. It is the word
  331. "program", followed directly by a colon, then the program name. A
  332. header value of ``[program:foo]`` describes a program with the name of
  333. "foo". The name is used within client applications that control the
  334. processes that are created as a result of this configuration. It is
  335. an error to create a ``program`` section that does not have a name.
  336. The name must not include a colon character or a bracket character.
  337. The value of the name is used as the value for the
  338. ``%(program_name)s`` string expression expansion within other values
  339. where specified.
  340. .. note::
  341. A ``[program:x]`` section actually represents a "homogeneous
  342. process group" to supervisor (as of 3.0). The members of the group
  343. are defined by the combination of the ``numprocs`` and
  344. ``process_name`` parameters in the configuration. By default, if
  345. numprocs and process_name are left unchanged from their defaults,
  346. the group represented by ``[program:x]`` will be named ``x`` and
  347. will have a single process named ``x`` in it. This provides a
  348. modicum of backwards compatibility with older supervisor releases,
  349. which did not treat program sections as homogeneous process group
  350. defnitions.
  351. But for instance, if you have a ``[program:foo]`` section with a
  352. ``numprocs`` of 3 and a ``process_name`` expression of
  353. ``%(program_name)s_%(process_num)02d``, the "foo" group will
  354. contain three processes, named ``foo_00``, ``foo_01``, and
  355. ``foo_02``. This makes it possible to start a number of very
  356. similar processes using a single ``[program:x]`` section. All
  357. logfile names, all environment strings, and the command of programs
  358. can also contain similar Python string expressions, to pass
  359. slightly different parameters to each process.
  360. ``[program:x]`` Section Values
  361. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  362. ``command``
  363. The command that will be run when this program is started. The
  364. command can be either absolute (e.g. ``/path/to/programname``) or
  365. relative (e.g. ``programname``). If it is relative, the
  366. supervisord's environment ``$PATH`` will be searched for the
  367. executable. Programs can accept arguments, e.g. ``/path/to/program
  368. foo bar``. The command line can use double quotes to group
  369. arguments with spaces in them to pass to the program,
  370. e.g. ``/path/to/program/name -p "foo bar"``. Note that the value of
  371. ``command`` may include Python string expressions,
  372. e.g. ``/path/to/programname --port=80%(process_num)02d`` might
  373. expand to ``/path/to/programname --port=8000`` at runtime. String
  374. expressions are evaluated against a dictionary containing the keys
  375. ``group_name``, ``host_node_name``, ``process_num``, ``program_name``,
  376. ``here`` (the directory of the supervisord config file), and all
  377. supervisord's environment variables prefixed with ``ENV_``. Controlled
  378. programs should themselves not be daemons, as supervisord assumes it is
  379. responsible for daemonizing its subprocesses (see
  380. :ref:`nondaemonizing_of_subprocesses`).
  381. *Default*: No default.
  382. *Required*: Yes.
  383. *Introduced*: 3.0
  384. ``process_name``
  385. A Python string expression that is used to compose the supervisor
  386. process name for this process. You usually don't need to worry
  387. about setting this unless you change ``numprocs``. The string
  388. expression is evaluated against a dictionary that includes
  389. ``group_name``, ``host_node_name``, ``process_num``, ``program_name``,
  390. and ``here`` (the directory of the supervisord config file).
  391. *Default*: ``%(program_name)s``
  392. *Required*: No.
  393. *Introduced*: 3.0
  394. ``numprocs``
  395. Supervisor will start as many instances of this program as named by
  396. numprocs. Note that if numprocs > 1, the ``process_name``
  397. expression must include ``%(process_num)s`` (or any other
  398. valid Python string expression that includes ``process_num``) within
  399. it.
  400. *Default*: 1
  401. *Required*: No.
  402. *Introduced*: 3.0
  403. ``numprocs_start``
  404. An integer offset that is used to compute the number at which
  405. ``numprocs`` starts.
  406. *Default*: 0
  407. *Required*: No.
  408. *Introduced*: 3.0
  409. ``priority``
  410. The relative priority of the program in the start and shutdown
  411. ordering. Lower priorities indicate programs that start first and
  412. shut down last at startup and when aggregate commands are used in
  413. various clients (e.g. "start all"/"stop all"). Higher priorities
  414. indicate programs that start last and shut down first.
  415. *Default*: 999
  416. *Required*: No.
  417. *Introduced*: 3.0
  418. ``autostart``
  419. If true, this program will start automatically when supervisord is
  420. started.
  421. *Default*: true
  422. *Required*: No.
  423. *Introduced*: 3.0
  424. ``autorestart``
  425. May be one of ``false``, ``unexpected``, or ``true``. If ``false``,
  426. the process will never be autorestarted. If ``unexpected``, the
  427. process will be restart when the program exits with an exit code
  428. that is not one of the exit codes associated with this process'
  429. configuration (see ``exitcodes``). If ``true``, the process will be
  430. unconditionally restarted when it exits, without regard to its exit
  431. code.
  432. *Default*: unexpected
  433. *Required*: No.
  434. *Introduced*: 3.0
  435. ``startsecs``
  436. The total number of seconds which the program needs to stay running
  437. after a startup to consider the start successful. If the program
  438. does not stay up for this many seconds after it has started, even if
  439. it exits with an "expected" exit code (see ``exitcodes``), the
  440. startup will be considered a failure. Set to ``0`` to indicate that
  441. the program needn't stay running for any particular amount of time.
  442. *Default*: 1
  443. *Required*: No.
  444. *Introduced*: 3.0
  445. ``startretries``
  446. The number of serial failure attempts that :program:`supervisord`
  447. will allow when attempting to start the program before giving up and
  448. puting the process into an ``FATAL`` state. See
  449. :ref:`process_states` for explanation of the ``FATAL`` state.
  450. *Default*: 3
  451. *Required*: No.
  452. *Introduced*: 3.0
  453. ``exitcodes``
  454. The list of "expected" exit codes for this program. If the
  455. ``autorestart`` parameter is set to ``unexpected``, and the process
  456. exits in any other way than as a result of a supervisor stop
  457. request, :program:`supervisord` will restart the process if it exits
  458. with an exit code that is not defined in this list.
  459. *Default*: 0,2
  460. *Required*: No.
  461. *Introduced*: 3.0
  462. ``stopsignal``
  463. The signal used to kill the program when a stop is requested. This
  464. can be any of TERM, HUP, INT, QUIT, KILL, USR1, or USR2.
  465. *Default*: TERM
  466. *Required*: No.
  467. *Introduced*: 3.0
  468. ``stopwaitsecs``
  469. The number of seconds to wait for the OS to return a SIGCHILD to
  470. :program:`supervisord` after the program has been sent a stopsignal.
  471. If this number of seconds elapses before :program:`supervisord`
  472. receives a SIGCHILD from the process, :program:`supervisord` will
  473. attempt to kill it with a final SIGKILL.
  474. *Default*: 10
  475. *Required*: No.
  476. *Introduced*: 3.0
  477. ``stopasgroup``
  478. If true, the flag causes supervisor to send the stop signal to the
  479. whole process group and implies ``killasgroup`` is true. This is useful
  480. for programs, such as Flask in debug mode, that do not propagate
  481. stop signals to their children, leaving them orphaned.
  482. *Default*: false
  483. *Required*: No.
  484. *Introduced*: 3.0b1
  485. ``killasgroup``
  486. If true, when resorting to send SIGKILL to the program to terminate
  487. it send it to its whole process group instead, taking care of its
  488. children as well, useful e.g with Python programs using
  489. :mod:`multiprocessing`.
  490. *Default*: false
  491. *Required*: No.
  492. *Introduced*: 3.0a11
  493. ``user``
  494. If :program:`supervisord` runs as root, this UNIX user account will
  495. be used as the account which runs the program. If :program:`supervisord`
  496. can't switch to the specified user, the program will not be started.
  497. *Default*: Do not switch users
  498. *Required*: No.
  499. *Introduced*: 3.0
  500. ``redirect_stderr``
  501. If true, cause the process' stderr output to be sent back to
  502. :program:`supervisord` on its stdout file descriptor (in UNIX shell
  503. terms, this is the equivalent of executing ``/the/program 2>&1``).
  504. *Default*: false
  505. *Required*: No.
  506. *Introduced*: 3.0, replaces 2.0's ``log_stdout`` and ``log_stderr``
  507. ``stdout_logfile``
  508. Put process stdout output in this file (and if redirect_stderr is
  509. true, also place stderr output in this file). If ``stdout_logfile``
  510. is unset or set to ``AUTO``, supervisor will automatically choose a
  511. file location. If this is set to ``NONE``, supervisord will create
  512. no log file. ``AUTO`` log files and their backups will be deleted
  513. when :program:`supervisord` restarts. The ``stdout_logfile`` value
  514. can contain Python string expressions that will evaluated against a
  515. dictionary that contains the keys ``group_name``, ``host_node_name``,
  516. ``process_num``, ``program_name``, and ``here`` (the directory of the
  517. supervisord config file).
  518. .. note::
  519. It is not possible for two processes to share a single log file
  520. (``stdout_logfile``) when rotation (``stdout_logfile_maxbytes``)
  521. is enabled. This will result in the file being corrupted.
  522. *Default*: ``AUTO``
  523. *Required*: No.
  524. *Introduced*: 3.0, replaces 2.0's ``logfile``
  525. ``stdout_logfile_maxbytes``
  526. The maximum number of bytes that may be consumed by
  527. ``stdout_logfile`` before it is rotated (suffix multipliers like
  528. "KB", "MB", and "GB" can be used in the value). Set this value to 0
  529. to indicate an unlimited log size.
  530. *Default*: 50MB
  531. *Required*: No.
  532. *Introduced*: 3.0, replaces 2.0's ``logfile_maxbytes``
  533. ``stdout_logfile_backups``
  534. The number of ``stdout_logfile`` backups to keep around resulting
  535. from process stdout log file rotation. If set to 0, no backups
  536. will be kept.
  537. *Default*: 10
  538. *Required*: No.
  539. *Introduced*: 3.0, replaces 2.0's ``logfile_backups``
  540. ``stdout_capture_maxbytes``
  541. Max number of bytes written to capture FIFO when process is in
  542. "stdout capture mode" (see :ref:`capture_mode`). Should be an
  543. integer (suffix multipliers like "KB", "MB" and "GB" can used in the
  544. value). If this value is 0, process capture mode will be off.
  545. *Default*: 0
  546. *Required*: No.
  547. *Introduced*: 3.0, replaces 2.0's ``logfile_backups``
  548. ``stdout_events_enabled``
  549. If true, PROCESS_LOG_STDOUT events will be emitted when the process
  550. writes to its stdout file descriptor. The events will only be
  551. emitted if the file descriptor is not in capture mode at the time
  552. the data is received (see :ref:`capture_mode`).
  553. *Default*: 0
  554. *Required*: No.
  555. *Introduced*: 3.0a7
  556. ``stderr_logfile``
  557. Put process stderr output in this file unless ``redirect_stderr`` is
  558. true. Accepts the same value types as ``stdout_logfile`` and may
  559. contain the same Python string expressions.
  560. .. note::
  561. It is not possible for two processes to share a single log file
  562. (``stderr_logfile``) when rotation (``stderr_logfile_maxbytes``)
  563. is enabled. This will result in the file being corrupted.
  564. *Default*: ``AUTO``
  565. *Required*: No.
  566. *Introduced*: 3.0
  567. ``stderr_logfile_maxbytes``
  568. The maximum number of bytes before logfile rotation for
  569. ``stderr_logfile``. Accepts the same value types as
  570. ``stdout_logfile_maxbytes``.
  571. *Default*: 50MB
  572. *Required*: No.
  573. *Introduced*: 3.0
  574. ``stderr_logfile_backups``
  575. The number of backups to keep around resulting from process stderr
  576. log file rotation. If set to 0, no backups will be kept.
  577. *Default*: 10
  578. *Required*: No.
  579. *Introduced*: 3.0
  580. ``stderr_capture_maxbytes``
  581. Max number of bytes written to capture FIFO when process is in
  582. "stderr capture mode" (see :ref:`capture_mode`). Should be an
  583. integer (suffix multipliers like "KB", "MB" and "GB" can used in the
  584. value). If this value is 0, process capture mode will be off.
  585. *Default*: 0
  586. *Required*: No.
  587. *Introduced*: 3.0
  588. ``stderr_events_enabled``
  589. If true, PROCESS_LOG_STDERR events will be emitted when the process
  590. writes to its stderr file descriptor. The events will only be
  591. emitted if the file descriptor is not in capture mode at the time
  592. the data is received (see :ref:`capture_mode`).
  593. *Default*: false
  594. *Required*: No.
  595. *Introduced*: 3.0a7
  596. ``environment``
  597. A list of key/value pairs in the form ``KEY="val",KEY2="val2"`` that
  598. will be placed in the child process' environment. The environment
  599. string may contain Python string expressions that will be evaluated
  600. against a dictionary containing ``group_name``, ``host_node_name``,
  601. ``process_num``, ``program_name``, and ``here`` (the directory of the
  602. supervisord config file). Values containing non-alphanumeric characters
  603. should be quoted (e.g. ``KEY="val:123",KEY2="val,456"``). Otherwise,
  604. quoting the values is optional but recommended. **Note** that the
  605. subprocess will inherit the environment variables of the shell used to
  606. start "supervisord" except for the ones overridden here. See
  607. :ref:`subprocess_environment`.
  608. *Default*: No extra environment
  609. *Required*: No.
  610. *Introduced*: 3.0
  611. ``directory``
  612. A file path representing a directory to which :program:`supervisord`
  613. should temporarily chdir before exec'ing the child.
  614. *Default*: No chdir (inherit supervisor's)
  615. *Required*: No.
  616. *Introduced*: 3.0
  617. ``umask``
  618. An octal number (e.g. 002, 022) representing the umask of the
  619. process.
  620. *Default*: No special umask (inherit supervisor's)
  621. *Required*: No.
  622. *Introduced*: 3.0
  623. ``serverurl``
  624. The URL passed in the environment to the subprocess process as
  625. ``SUPERVISOR_SERVER_URL`` (see :mod:`supervisor.childutils`) to
  626. allow the subprocess to easily communicate with the internal HTTP
  627. server. If provided, it should have the same syntax and structure
  628. as the ``[supervisorctl]`` section option of the same name. If this
  629. is set to AUTO, or is unset, supervisor will automatically construct
  630. a server URL, giving preference to a server that listens on UNIX
  631. domain sockets over one that listens on an internet socket.
  632. *Default*: AUTO
  633. *Required*: No.
  634. *Introduced*: 3.0
  635. ``[program:x]`` Section Example
  636. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  637. .. code-block:: ini
  638. [program:cat]
  639. command=/bin/cat
  640. process_name=%(program_name)s
  641. numprocs=1
  642. directory=/tmp
  643. umask=022
  644. priority=999
  645. autostart=true
  646. autorestart=true
  647. startsecs=10
  648. startretries=3
  649. exitcodes=0,2
  650. stopsignal=TERM
  651. stopwaitsecs=10
  652. user=chrism
  653. redirect_stderr=false
  654. stdout_logfile=/a/path
  655. stdout_logfile_maxbytes=1MB
  656. stdout_logfile_backups=10
  657. stdout_capture_maxbytes=1MB
  658. stderr_logfile=/a/path
  659. stderr_logfile_maxbytes=1MB
  660. stderr_logfile_backups=10
  661. stderr_capture_maxbytes=1MB
  662. environment=A="1",B="2"
  663. serverurl=AUTO
  664. ``[include]`` Section Settings
  665. ------------------------------
  666. The :file:`supervisord.conf` file may contain a section named
  667. ``[include]``. If the configuration file contains an ``[include]``
  668. section, it must contain a single key named "files". The values in
  669. this key specify other configuration files to be included within the
  670. configuration.
  671. ``[include]`` Section Values
  672. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  673. ``files``
  674. A space-separated sequence of file globs. Each file glob may be
  675. absolute or relative. If the file glob is relative, it is
  676. considered relative to the location of the configuration file which
  677. includes it. A "glob" is a file pattern which matches a specified
  678. pattern according to the rules used by the Unix shell. No tilde
  679. expansion is done, but ``*``, ``?``, and character ranges expressed
  680. with ``[]`` will be correctly matched. Recursive includes from
  681. included files are not supported.
  682. *Default*: No default (required)
  683. *Required*: Yes.
  684. *Introduced*: 3.0
  685. ``[include]`` Section Example
  686. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  687. .. code-block:: ini
  688. [include]
  689. files = /an/absolute/filename.conf /an/absolute/*.conf foo.conf config??.conf
  690. ``[group:x]`` Section Settings
  691. ------------------------------
  692. It is often useful to group "homogeneous" processes groups (aka
  693. "programs") together into a "heterogeneous" process group so they can
  694. be controlled as a unit from Supervisor's various controller
  695. interfaces.
  696. To place programs into a group so you can treat them as a unit, define
  697. a ``[group:x]`` section in your configuration file. The group header
  698. value is a composite. It is the word "group", followed directly by a
  699. colon, then the group name. A header value of ``[group:foo]``
  700. describes a group with the name of "foo". The name is used within
  701. client applications that control the processes that are created as a
  702. result of this configuration. It is an error to create a ``group``
  703. section that does not have a name. The name must not include a colon
  704. character or a bracket character.
  705. For a ``[group:x]``, there must be one or more ``[program:x]``
  706. sections elsewhere in your configuration file, and the group must
  707. refer to them by name in the ``programs`` value.
  708. If "homogeneous" program groups" (represented by program sections) are
  709. placed into a "heterogeneous" group via ``[group:x]`` section's
  710. ``programs`` line, the homogeneous groups that are implied by the
  711. program section will not exist at runtime in supervisor. Instead, all
  712. processes belonging to each of the homogeneous groups will be placed
  713. into the heterogeneous group. For example, given the following group
  714. configuration:
  715. .. code-block:: ini
  716. [group:foo]
  717. programs=bar,baz
  718. priority=999
  719. Given the above, at supervisord startup, the ``bar`` and ``baz``
  720. homogeneous groups will not exist, and the processes that would have
  721. been under them will now be moved into the ``foo`` group.
  722. ``[group:x]`` Section Values
  723. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  724. ``programs``
  725. A comma-separated list of program names. The programs which are
  726. listed become members of the group.
  727. *Default*: No default (required)
  728. *Required*: Yes.
  729. *Introduced*: 3.0
  730. ``priority``
  731. A priority number analogous to a ``[program:x]`` priority value
  732. assigned to the group.
  733. *Default*: 999
  734. *Required*: No.
  735. *Introduced*: 3.0
  736. ``[group:x]`` Section Example
  737. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  738. .. code-block:: ini
  739. [group:foo]
  740. programs=bar,baz
  741. priority=999
  742. ``[fcgi-program:x]`` Section Settings
  743. -------------------------------------
  744. Supervisor can manage groups of `FastCGI <http://www.fastcgi.com>`_
  745. processes that all listen on the same socket. Until now, deployment
  746. flexibility for FastCGI was limited. To get full process management,
  747. you could use mod_fastcgi under Apache but then you were stuck with
  748. Apache's inefficient concurrency model of one process or thread per
  749. connection. In addition to requiring more CPU and memory resources,
  750. the process/thread per connection model can be quickly saturated by a
  751. slow resource, preventing other resources from being served. In order
  752. to take advantage of newer event-driven web servers such as lighttpd
  753. or nginx which don't include a built-in process manager, you had to
  754. use scripts like cgi-fcgi or spawn-fcgi. These can be used in
  755. conjunction with a process manager such as supervisord or daemontools
  756. but require each FastCGI child process to bind to its own socket.
  757. The disadvantages of this are: unnecessarily complicated web server
  758. configuration, ungraceful restarts, and reduced fault tolerance. With
  759. fewer sockets to configure, web server configurations are much smaller
  760. if groups of FastCGI processes can share sockets. Shared sockets
  761. allow for graceful restarts because the socket remains bound by the
  762. parent process while any of the child processes are being restarted.
  763. Finally, shared sockets are more fault tolerant because if a given
  764. process fails, other processes can continue to serve inbound
  765. connections.
  766. With integrated FastCGI spawning support, Supervisor gives you the
  767. best of both worlds. You get full-featured process management with
  768. groups of FastCGI processes sharing sockets without being tied to a
  769. particular web server. It's a clean separation of concerns, allowing
  770. the web server and the process manager to each do what they do best.
  771. Note that all the options available to ``[program:x]`` sections are
  772. also respected by fcgi-program sections.
  773. ``[fcgi-program:x]`` Section Values
  774. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  775. ``[fcgi-program:x]`` sections have a single key which ``[program:x]``
  776. sections do not have.
  777. ``socket``
  778. The FastCGI socket for this program, either TCP or UNIX domain
  779. socket. For TCP sockets, use this format: ``tcp://localhost:9002``.
  780. For UNIX domain sockets, use ``unix:///absolute/path/to/file.sock``.
  781. String expressions are evaluated against a dictionary containing the
  782. keys "program_name" and "here" (the directory of the supervisord
  783. config file).
  784. *Default*: No default.
  785. *Required*: Yes.
  786. *Introduced*: 3.0
  787. ``socket_owner``
  788. For UNIX domain sockets, this parameter can be used to specify the user
  789. and group for the FastCGI socket. May be a UNIX username (e.g. chrism)
  790. or a UNIX username and group separated by a colon (e.g. chrism:wheel).
  791. *Default*: Uses the user and group set for the fcgi-program
  792. *Required*: No.
  793. *Introduced*: 3.0
  794. ``socket_mode``
  795. For UNIX domain sockets, this parameter can be used to specify the
  796. permission mode.
  797. *Default*: 0700
  798. *Required*: No.
  799. *Introduced*: 3.0
  800. Consult :ref:`programx_section` for other allowable keys, delta the
  801. above constraints and additions.
  802. ``[fcgi-program:x]`` Section Example
  803. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  804. .. code-block:: ini
  805. [fcgi-program:fcgiprogramname]
  806. command=/usr/bin/example.fcgi
  807. socket=unix:///var/run/supervisor/%(program_name)s.sock
  808. process_name=%(program_name)s_%(process_num)02d
  809. numprocs=5
  810. priority=999
  811. autostart=true
  812. autorestart=unexpected
  813. startsecs=1
  814. startretries=3
  815. exitcodes=0,2
  816. stopsignal=QUIT
  817. stopwaitsecs=10
  818. user=chrism
  819. redirect_stderr=true
  820. stdout_logfile=/a/path
  821. stdout_logfile_maxbytes=1MB
  822. stdout_logfile_backups=10
  823. stderr_logfile=/a/path
  824. stderr_logfile_maxbytes=1MB
  825. stderr_logfile_backups
  826. environment=A="1",B="2"
  827. ``[eventlistener:x]`` Section Settings
  828. --------------------------------------
  829. Supervisor allows specialized homogeneous process groups ("event
  830. listener pools") to be defined within the configuration file. These
  831. pools contain processes that are meant to receive and respond to event
  832. notifications from supervisor's event system. See :ref:`events` for
  833. an explanation of how events work and how to implement programs that
  834. can be declared as event listeners.
  835. Note that all the options available to ``[program:x]`` sections are
  836. respected by eventlistener sections *except* for
  837. ``stdout_capture_maxbytes`` and ``stderr_capture_maxbytes`` (event
  838. listeners cannot emit process communication events, see
  839. :ref:`capture_mode`).
  840. ``[eventlistener:x]`` Section Values
  841. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  842. ``[eventlistener:x]`` sections have a few keys which ``[program:x]``
  843. sections do not have.
  844. ``buffer_size``
  845. The event listener pool's event queue buffer size. When a listener
  846. pool's event buffer is overflowed (as can happen when an event
  847. listener pool cannot keep up with all of the events sent to it), the
  848. oldest event in the buffer is discarded.
  849. ``events``
  850. A comma-separated list of event type names that this listener is
  851. "interested" in receiving notifications for (see
  852. :ref:`event_types` for a list of valid event type names).
  853. ``result_handler``
  854. A `pkg_resources entry point string
  855. <http://peak.telecommunity.com/DevCenter/PkgResources>`_ that
  856. resolves to a Python callable. The default value is
  857. ``supervisor.dispatchers:default_handler``. Specifying an alternate
  858. result handler is a very uncommon thing to need to do, and as a
  859. result, how to create one is not documented.
  860. Consult :ref:`programx_section` for other allowable keys, delta the
  861. above constraints and additions.
  862. ``[eventlistener:x]`` Section Example
  863. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  864. .. code-block:: ini
  865. [eventlistener:theeventlistenername]
  866. command=/bin/eventlistener
  867. process_name=%(program_name)s_%(process_num)02d
  868. numprocs=5
  869. events=PROCESS_STATE
  870. buffer_size=10
  871. priority=-1
  872. autostart=true
  873. autorestart=unexpected
  874. startsecs=1
  875. startretries=3
  876. exitcodes=0,2
  877. stopsignal=QUIT
  878. stopwaitsecs=10
  879. user=chrism
  880. redirect_stderr=true
  881. stdout_logfile=/a/path
  882. stdout_logfile_maxbytes=1MB
  883. stdout_logfile_backups=10
  884. stderr_logfile=/a/path
  885. stderr_logfile_maxbytes=1MB
  886. stderr_logfile_backups
  887. environment=A="1",B="2"
  888. ``[rpcinterface:x]`` Section Settings
  889. -------------------------------------
  890. Adding ``rpcinterface:x`` settings in the configuration file is only
  891. useful for people who wish to extend supervisor with additional custom
  892. behavior.
  893. In the sample config file, there is a section which is named
  894. ``[rpcinterface:supervisor]``. By default it looks like the
  895. following.
  896. .. code-block:: ini
  897. [rpcinterface:supervisor]
  898. supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
  899. The ``[rpcinterface:supervisor]`` section *must* remain in the
  900. configuration for the standard setup of supervisor to work properly.
  901. If you don't want supervisor to do anything it doesn't already do out
  902. of the box, this is all you need to know about this type of section.
  903. However, if you wish to add rpc interface namespaces in order to
  904. customize supervisor, you may add additional ``[rpcinterface:foo]``
  905. sections, where "foo" represents the namespace of the interface (from
  906. the web root), and the value named by
  907. ``supervisor.rpcinterface_factory`` is a factory callable which should
  908. have a function signature that accepts a single positional argument
  909. ``supervisord`` and as many keyword arguments as required to perform
  910. configuration. Any extra key/value pairs defined within the
  911. ``[rpcinterface:x]`` section will be passed as keyword arguments to
  912. the factory.
  913. Here's an example of a factory function, created in the
  914. ``__init__.py`` file of the Python package ``my.package``.
  915. .. code-block:: python
  916. from my.package.rpcinterface import AnotherRPCInterface
  917. def make_another_rpcinterface(supervisord, **config):
  918. retries = int(config.get('retries', 0))
  919. another_rpc_interface = AnotherRPCInterface(supervisord, retries)
  920. return another_rpc_interface
  921. And a section in the config file meant to configure it.
  922. .. code-block:: ini
  923. [rpcinterface:another]
  924. supervisor.rpcinterface_factory = my.package:make_another_rpcinterface
  925. retries = 1
  926. ``[rpcinterface:x]`` Section Values
  927. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  928. ``supervisor.rpcinterface_factory``
  929. ``pkg_resources`` "entry point" dotted name to your RPC interface's
  930. factory function.
  931. *Default*: N/A
  932. *Required*: No.
  933. *Introduced*: 3.0
  934. ``[rpcinterface:x]`` Section Example
  935. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  936. .. code-block:: ini
  937. [rpcinterface:another]
  938. supervisor.rpcinterface_factory = my.package:make_another_rpcinterface
  939. retries = 1