configuration.rst 38 KB

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