configuration.rst 40 KB

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