configuration.rst 38 KB

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