configuration.rst 39 KB

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