events.rst 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  1. Events
  2. ======
  3. Events are an advanced feature of Supervisor introduced in version
  4. 3.0. You don't need to understand events if you simply want to use
  5. Supervisor as a mechanism to restart crashed processes or as a system
  6. to manually control process state. You do need to understand events
  7. if you want to use Supervisor as part of a process
  8. monitoring/notification framework.
  9. Event Listeners and Event Notifications
  10. ---------------------------------------
  11. Supervisor provides a way for a specially written program (which it
  12. runs as a subprocess) called an "event listener" to subscribe to
  13. "event notifications". An event notification implies that something
  14. happened related to a subprocess controlled by :program:`supervisord`
  15. or to :program:`supervisord` itself. Event notifications are grouped
  16. into types in order to make it possible for event listeners to
  17. subscribe to a limited subset of event notifications. Supervisor
  18. continually emits event notifications as its running even if there are
  19. no listeners configured. If a listener is configured and subscribed
  20. to an event type that is emitted during a :program:`supervisord`
  21. lifetime, that listener will be notified.
  22. The purpose of the event notification/subscription system is to
  23. provide a mechanism for arbitrary code to be run (e.g. send an email,
  24. make an HTTP request, etc) when some condition is met. That condition
  25. usually has to do with subprocess state. For instance, you may want
  26. to notify someone via email when a process crashes and is restarted by
  27. Supervisor.
  28. The event notification protocol is based on communication via a
  29. subprocess' stdin and stdout. Supervisor sends specially-formatted
  30. input to an event listener process' stdin and expects
  31. specially-formatted output from an event listener's stdout, forming a
  32. request-response cycle. A protocol agreed upon between supervisor and
  33. the listener's implementer allows listeners to process event
  34. notifications. Event listeners can be written in any language
  35. supported by the platform you're using to run Supervisor. Although
  36. event listeners may be written in any language, there is special
  37. library support for Python in the form of a
  38. :mod:`supervisor.childutils` module, which makes creating event
  39. listeners in Python slightly easier than in other languages.
  40. Configuring an Event Listener
  41. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  42. A supervisor event listener is specified via a ``[eventlistener:x]``
  43. section in the configuration file. Supervisor ``[eventlistener:x]``
  44. sections are treated almost exactly like supervisor ``[program:x]``
  45. section with the respect to the keys allowed in their configuration
  46. except that Supervisor does not respect "capture mode" output from
  47. event listener processes (ie. event listeners cannot be
  48. ``PROCESS_COMMUNICATIONS_EVENT`` event generators). Therefore it is
  49. an error to specify ``stdout_capture_maxbytes`` or
  50. ``stderr_capture_maxbytes`` in the configuration of an eventlistener.
  51. There is no artificial constraint on the number of eventlistener
  52. sections that can be placed into the configuration file.
  53. When an ``[eventlistener:x]`` section is defined, it actually defines
  54. a "pool", where the number of event listeners in the pool is
  55. determined by the ``numprocs`` value within the section.
  56. The ``events`` parameter of the ``[eventlistener:x]`` section
  57. specifies the events that will be sent to a listener pool. A
  58. well-written event listener will ignore events that it cannot process,
  59. but there is no guarantee that a specific event listener won't crash
  60. as a result of receiving an event type it cannot handle. Therefore,
  61. depending on the listener implementation, it may be important to
  62. specify in the configuration that it may receive only certain types of
  63. events. The implementor of the event listener is the only person who
  64. can tell you what these are (and therefore what value to put in the
  65. <code>events</code> configuration). Examples of eventlistener
  66. configurations that can be placed in ``supervisord.conf`` are as
  67. follows.
  68. .. code-block:: ini
  69. [eventlistener:memmon]
  70. command=memmon -a 200MB -m bob@example.com
  71. events=TICK_60
  72. .. code-block:: ini
  73. [eventlistener:mylistener]
  74. command=my_custom_listener.py
  75. events=PROCESS_STATE_CHANGE,TICK_60
  76. .. note::
  77. An advanced feature, specifying an alternate "result handler" for a
  78. pool, can be specified via the ``result_handler`` parameter of an
  79. ``[eventlistener:x]`` section in the form of a `pkg_resources
  80. <http://peak.telecommunity.com/DevCenter/PkgResources>`_ "entry
  81. point" string. The default result handler is
  82. ``supervisord.dispatchers:default_handler``. Creating an alternate
  83. result handler is not currently documented.
  84. When an event notification is sent by supervisor, all event listener
  85. pools which are subscribed to receive events for the event's type
  86. (filtered by the ``events`` value in the eventlistener
  87. section) will be found. One of the listeners in each listener pool
  88. will receive the event notification (any "available" listener).
  89. Every process in an event listener pool is treated equally by
  90. supervisor. If a process in the pool is unavailable (because it is
  91. already processing an event, because it has crashed, or because it has
  92. elected to removed itself from the pool), supervisor will choose
  93. another process from the pool. If the event cannot be sent because
  94. all listeners in the pool are "busy", the event will be buffered and
  95. notification will be retried later. "Later" is defined as "the next
  96. time that the :program:`supervisord` select loop executes". For
  97. satisfactory event processing performance, you should configure a pool
  98. with as many event listener processes as appropriate to handle your
  99. event load. This can only be determined empirically for any given
  100. workload, there is no "magic number" but to help you determine the
  101. optimal number of listeners in a given pool, Supervisor will emit
  102. warning messages to its activity log when an event cannot be sent
  103. immediately due to pool congestion. There is no artificial constraint
  104. placed on the number of processes that can be in a pool, it is limited
  105. only by your platform constraints.
  106. A listener pool has an event buffer queue. The queue is sized via the
  107. listener pool's ``buffer_size`` config file option. If the queue is
  108. full and supervisor attempts to buffer an event, supervisor will throw
  109. away the oldest event in the buffer and log an error.
  110. Writing an Event Listener
  111. ~~~~~~~~~~~~~~~~~~~~~~~~~
  112. An event listener implementation is a program that is willing to
  113. accept structured input on its stdin stream and produce structured
  114. output on its stdout stream. An event listener implementation should
  115. operate in "unbuffered" mode or should flush its stdout every time it
  116. needs to communicate back to the supervisord process. Event listeners
  117. can be written to be long-running or may exit after a single request
  118. (depending on the implementation and the ``autorestart`` parameter in
  119. the eventlistener's configuration).
  120. An event listener can send arbitrary output to its stderr, which will
  121. be logged or ignored by supervisord depending on the stderr-related
  122. logfile configuration in its ``[eventlistener:x]`` section.
  123. Event Notification Protocol
  124. +++++++++++++++++++++++++++
  125. When supervisord sends a notification to an event listener process,
  126. the listener will first be sent a single "header" line on its
  127. stdin. The composition of the line is a set of colon-separated tokens
  128. (each of which represents a key-value pair) separated from each other
  129. by a single space. The line is terminated with a ``\n`` (linefeed)
  130. character. The tokens on the line are not guaranteed to be in any
  131. particular order. The types of tokens currently defined are in the
  132. table below.
  133. Header Tokens
  134. @@@@@@@@@@@@@
  135. =========== ============================================= ===================
  136. Key Description Example
  137. =========== ============================================= ===================
  138. ver The event system protocol version 3.0
  139. server The identifier of the supervisord sending the
  140. event (see config file ``[supervisord]``
  141. section ``identifier`` value.
  142. serial An integer assigned to each event. No two 30
  143. events generated during the lifetime of
  144. a :program:`supervisord` process will have
  145. the same serial number. The value is useful
  146. for functional testing and detecting event
  147. ordering anomalies.
  148. pool The name of the event listener pool which myeventpool
  149. generated this event.
  150. pooolserial An integer assigned to each event by the 30
  151. eventlistener pool which it is being sent
  152. from. No two events generated by the same
  153. eventlister pool during the lifetime of a
  154. :program:`supervisord` process will have the
  155. same ``poolserial`` number. This value can
  156. be used to detect event ordering anomalies.
  157. eventname The specific event type name (see "Supervisor TICK_5
  158. Events" elsewhere in this document)
  159. len An integer indicating the number of bytes in 22
  160. the event payload, aka the ``PAYLOAD_LENGTH``
  161. =========== ============================================= ===================
  162. An example of a complete header line is as follows.
  163. .. code-block:: text
  164. ver:3.0 server:supervisor serial:21 pool:listener poolserial:10 eventname:PROCESS_COMMUNICATION_STDOUT len:54
  165. Directly following the linefeed character in the header is the event
  166. payload. It consists of ``PAYLOAD_LENGTH`` bytes representing a
  167. serialization of the event data. See "Supervisor Event Types"
  168. elsewhere for the specific event data serialization definitions.
  169. An example payload for a ``PROCESS_COMMUNICATION_STDOUT`` event
  170. notification is as follows.
  171. .. code-block:: text
  172. process_name:foo group_name:bar pid:123
  173. This is the data that was sent between the tags
  174. The payload structure of any given event is determined only by the
  175. event's type.
  176. Event Listener States
  177. +++++++++++++++++++++
  178. An event listener process has three possible states that are
  179. maintained by supervisord:
  180. ============================= ==============================================
  181. Name Description
  182. ============================= ==============================================
  183. ACKNOWLEDGED The event listener has acknowledged (accepted
  184. or rejected) an event send.
  185. READY Event notificatons may be sent to this event
  186. listener
  187. BUSY Event notifications may not be sent to this
  188. event listener.
  189. ============================= ==============================================
  190. When an event listener process first starts, supervisor automatically
  191. places it into the ``ACKNOWLEDGED`` state to allow for startup
  192. activities or guard against startup failures (hangs). Until the
  193. listener sends a ``READY\n`` string to its stdout, it will stay in
  194. this state.
  195. When supervisor sends an event notification to a listener in the
  196. ``READY`` state, the listener will be placed into the ``BUSY`` state
  197. until it receives an ``OK`` or ``FAIL`` response from the listener, at
  198. which time, the listener will be transitioned back into the
  199. ``ACKNOWLEDGED`` state.
  200. Event Listener Notification Protocol
  201. ++++++++++++++++++++++++++++++++++++
  202. Supervisor will notify an event listener in the ``READY`` state of an
  203. event by sending data to the stdin of the process. Supervisor will
  204. never send anything to the stdin of an event listener process while
  205. that process is in the ``BUSY`` or ``ACKNOWLEDGED`` state. Supervisor
  206. starts by sending the header.
  207. Once it has processed the header, the event listener implementation
  208. should read ``PAYLOAD_LENGTH`` bytes from its stdin, perform an
  209. arbitrary action based on the values in the header and the data parsed
  210. out of the serialization. It is free to block for an arbitrary amount
  211. of time while doing this. Supervisor will continue processing
  212. normally as it waits for a response and it will send other events of
  213. the same type to other listener processes in the same pool as
  214. necessary.
  215. After the event listener has processed the event serialization, in
  216. order to notify supervisord about the result, it should send back a
  217. result structure on its stdout. A result structure is the word
  218. "RESULT", followed by a space, followed by the result length, followed
  219. by a carriage return, follwed by the result content. For example,
  220. ``RESULT 2\nOK`` is the result "OK". Conventionally, an event
  221. listener will use either ``OK`` or ``FAIL`` as the result content.
  222. These strings have special meaning to the default result handler.
  223. If the defaut result handler receives ``OK`` as result content, it
  224. will assume that the listener processed the event notification
  225. successfully. If it receives ``FAIL``, it will assume that the
  226. listener has failed to process the event, and the event will be
  227. rebuffered and sent again at a later time. The event listener may
  228. reject the event for any reason by returning a ``FAIL`` result. This
  229. does not indicate a problem with the event data or the event listener.
  230. Once an ``OK`` or ``FAIL`` result is received by supervisord, the
  231. event listener is placed into the ``ACKNOWLEDGED`` state.
  232. Once the listener is in the ``ACKNOWLEDGED`` state, it may either exit
  233. (and subsequently may be restarted by supervisor if its
  234. ``autorestart`` config parameter is ``true``), or it may continue
  235. running. If it continues to run, in order to be placed back into the
  236. ``READY`` state by supervisord, it must send a ``READY`` token
  237. followed immediately by a carriage return to its stdout.
  238. Example Event Listener Implementation
  239. +++++++++++++++++++++++++++++++++++++
  240. A Python implementation of a "long-running" event listener which
  241. accepts an event notification, prints the header and payload to its
  242. stderr, and responds with an ``OK`` result, and then subsequently a
  243. ``READY`` is as follows.
  244. .. code-block:: python
  245. import sys
  246. def write_stdout(s):
  247. sys.stdout.write(s)
  248. sys.stdout.flush()
  249. def write_stderr(s):
  250. sys.stderr.write(s)
  251. sys.stderr.flush()
  252. def main():
  253. while 1:
  254. write_stdout('READY\n') # transition from ACKNOWLEDGED to READY
  255. line = sys.stdin.readline() # read header line from stdin
  256. write_stderr(line) # print it out to stderr
  257. headers = dict([ x.split(':') for x in line.split() ])
  258. data = sys.stdin.read(int(headers['len'])) # read the event payload
  259. write_stderr(data) # print the event payload to stderr
  260. write_stdout('RESULT 2\nOK') # transition from READY to ACKNOWLEDGED
  261. if __name__ == '__main__':
  262. main()
  263. import sys
  264. Other sample event listeners are present within the :term:`superlance`
  265. package, including one which can monitor supervisor subprocesses and
  266. restart a process if it is using "too much" memory.
  267. Event Listener Error Conditions
  268. +++++++++++++++++++++++++++++++
  269. If the event listener process dies while the event is being
  270. transmitted to its stdin, or if it dies before sending an result
  271. structure back to supervisord, the event is assumed to not be
  272. processed and will be rebuffered by supervisord and sent again later.
  273. If an event listener sends data to its stdout which supervisor does
  274. not recognize as an appropriate response based on the state that the
  275. event listener is in, the event listener will be placed into the
  276. ``UNKNOWN`` state, and no further event notifications will be sent to
  277. it. If an event was being processed by the listener during this time,
  278. it will be rebuffered and sent again later.
  279. Miscellaneous
  280. +++++++++++++
  281. Event listeners may use the Supervisor XML-RPC interface to call "back
  282. in" to Supervisor. As such, event listeners can impact the state of a
  283. Supervisor subprocess as a result of receiving an event notification.
  284. For example, you may want to generate an event every few minutes
  285. related to process usage of Supervisor-controlled subprocesses, and if
  286. any of those processes exceed some memory threshhold, you would like
  287. to restart it. You would write a program that caused supervisor to
  288. generate ``PROCESS_COMMUNICATION`` events every so often with memory
  289. information in them, and an event listener to perform an action based
  290. on processing the data it receives from these events.
  291. Event Types
  292. -----------
  293. The event types are a controlled set, defined by Supervisor itself.
  294. There is no way to add an event type without changing
  295. :program:`supervisord` itself. This is typically not a problem,
  296. though, because metadata is attached to events that can be used by
  297. event listeners as additional filter criterion, in conjunction with
  298. its type.
  299. Event types that may be subscribed to by event listeners are
  300. predefined by supervisor and fall into several major categories,
  301. including "process state change", "process communication", and
  302. "supervisor state change" events. Below are tables describing
  303. these event types.
  304. In the below list, we indicate that some event types have a "body"
  305. which is a a *token set*. A token set consists of a set of charaters
  306. with space-separated tokens. Each token represents a key-value pair.
  307. The key and value are separated by a colon. For example:
  308. .. code-block:: text
  309. processname:cat groupname:cat from_state:STOPPED
  310. Token sets do not have a linefeed or carriage return character at
  311. their end.
  312. ``EVENT`` Event Type
  313. ~~~~~~~~~~~~~~~~~~~~
  314. The base event type. This event type is abstract. It will never be
  315. sent directly. Subscribing to this event type will cause a subscriber
  316. to receive all event notifications emitted by Supervisor.
  317. *Name*: ``EVENT``
  318. *Subtype Of*: N/A
  319. *Body Description*: N/A
  320. ``PROCESS_STATE`` Event Type
  321. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  322. This process type indicates a process has moved from one state to
  323. another. See the process state map in "Subprocesses" elsewhere in
  324. this document for a description of the states that a process moves
  325. through during its lifetime. This event type is abstract, it will
  326. never be sent directly. Subscribing to this event type will cause a
  327. subscriber to receive event notifications of all the event types that
  328. are subtypes of ``PROCESS_STATE``.
  329. *Name*: ``PROCESS_STATE``
  330. *Subtype Of*: ``EVENT``
  331. Body Description
  332. ++++++++++++++++
  333. All subtypes of ``PROCESS_STATE`` have a body which is a token set.
  334. Additionally, each ``PROCESS_STATE`` subtype's token set has a default
  335. set of key/value pairs: ``processname``, ``groupname``, and
  336. ``from_state``. ``processname`` represents the process name which
  337. supervisor knows this process as. ``groupname`` represents the name of
  338. the supervisord group which this process is in. ``from_state`` is the
  339. name of the state from which this process is transitioning (the new
  340. state is implied by the concrete event type). Concrete subtypes may
  341. include additional key/value pairs in the token set.
  342. ``PROCESS_STATE_STARTING`` Event Type
  343. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  344. Indicates a process has moved from a state to the STARTING state.
  345. *Name*: ``PROCESS_STATE_STARTING``
  346. *Subtype Of*: ``PROCESS_STATE``
  347. Body Description
  348. ++++++++++++++++
  349. This body is a token set. It has the default set of key/value pairs
  350. plus an additional ``tries`` key. ``tries`` represents the number of
  351. times this process has entered this state before transitioning to
  352. RUNNING or FATAL (it will never be larger than the "startretries"
  353. parameter of the process). For example:
  354. .. code-block:: text
  355. processname:cat groupname:cat from_state:STOPPED tries:0
  356. ``PROCESS_STATE_RUNNING`` Event Type
  357. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  358. Indicates a process has moved from the ``STARTING`` state to the
  359. ``RUNNING`` state. This means that the process has successfully
  360. started as far as Supervisor is concerned.
  361. *Name*: ``PROCESS_STATE_RUNNING``
  362. *Subtype Of*: ``PROCESS_STATE``
  363. This body is a token set. It has the default set of key/value pairs
  364. plus an additional ``pid`` key. <code>pid</code> represents the UNIX
  365. process id of the process that was started. For example:
  366. .. code-block:: text
  367. processname:cat groupname:cat from_state:STARTING pid:2766
  368. ``PROCESS_STATE_BACKOFF`` Event Type
  369. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  370. Indicates a process has moved from the ``STARTING`` state to the
  371. ``BACKOFF`` state. This means that the process did not successfully
  372. enter the RUNNING state, and Supervisor is going to try to restart it
  373. unless it has exceeded its "startretries" configuration limit.
  374. *Name*: ``PROCESS_STATE_BACKOFF``
  375. *Subtype Of*: ``PROCESS_STATE``
  376. Body Description
  377. ++++++++++++++++
  378. This body is a token set. It has the default set of key/value pairs
  379. plus an additional ``tries`` key. ``tries`` represents the number of
  380. times this process has entered this state before transitioning to
  381. ``RUNNING`` or ``FATAL`` (it will never be larger than the
  382. "startretries" parameter of the process). For example:
  383. .. code-block:: text
  384. processname:cat groupname:cat from_state:STOPPED tries:0
  385. ``PROCESS_STATE_STOPPING`` Event Type
  386. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  387. Indicates a process has moved from either the ``RUNNING`` state or the
  388. ``STARTING`` state to the ``STOPPING`` state.
  389. *Name*: ``PROCESS_STATE_STOPPING``
  390. *Subtype Of*: ``PROCESS_STATE``
  391. Body Description
  392. ++++++++++++++++
  393. This body is a token set. It has the default set of key/value pairs
  394. plus an additional ``pid`` key. ``pid`` represents the UNIX process
  395. id of the process that was started. For example:
  396. .. code-block:: text
  397. processname:cat groupname:cat from_state:STARTING pid:2766
  398. ``PROCESS_STATE_EXITED`` Event Type
  399. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  400. Indicates a process has moved from the ``RUNNING`` state to the
  401. ``EXITED`` state.
  402. *Name*: ``PROCESS_STATE_EXITED``
  403. *Subtype Of*: ``PROCESS_STATE``
  404. Body Description
  405. ++++++++++++++++
  406. This body is a token set. It has the default set of key/value pairs
  407. plus two additional keys: ``pid`` and ``expected``. ``pid``
  408. represents the UNIX process id of the process that exited.
  409. ``expected`` represents whether the process exited with an expected
  410. exit code or not. It will be ``0`` if the exit code was unexpected,
  411. or ``1`` if the exit code was expected. For example:
  412. .. code-block:: text
  413. processname:cat groupname:cat from_state:RUNNING expected:0 pid:2766
  414. ``PROCESS_STATE_STOPPED`` Event Type
  415. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  416. Indicates a process has moved from the ``STOPPING`` state to the
  417. ``STOPPED`` state.
  418. *Name*: ``PROCESS_STATE_STOPPED``
  419. *Subtype Of*: ``PROCESS_STATE``
  420. Body Description
  421. ++++++++++++++++
  422. This body is a token set. It has the default set of key/value pairs
  423. plus an additional ``pid`` key. ``pid`` represents the UNIX process
  424. id of the process that was started. For example:
  425. .. code-block:: text
  426. processname:cat groupname:cat from_state:STOPPING pid:2766
  427. ``PROCESS_STATE_FATAL`` Event Type
  428. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  429. Indicates a process has moved from the ``BACKOFF`` state to the
  430. ``FATAL`` state. This means that Supervisor tried ``startretries``
  431. number of times unsuccessfully to start the process, and gave up
  432. attempting to restart it.
  433. *Name*: ``PROCESS_STATE_FATAL``
  434. *Subtype Of*: ``PROCESS_STATE``
  435. Body Description
  436. ++++++++++++++++
  437. This event type is a token set with the default key/value pairs. For
  438. example:
  439. .. code-block:: text
  440. processname:cat groupname:cat from_state:BACKOFF
  441. ``PROCESS_STATE_UNKNOWN`` Event Type
  442. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  443. Indicates a process has moved from any state to the ``UNKNOWN`` state
  444. (indicates an error in :program:`supervisord`). This state transition
  445. will only happen if :program:`supervisord` itself has a programming
  446. error.
  447. *Name*: ``PROCESS_STATE_UNKNOWN``
  448. *Subtype Of*: ``PROCESS_STATE``
  449. Body Description
  450. ++++++++++++++++
  451. This event type is a token set with the default key/value pairs. For
  452. example:
  453. .. code-block:: text
  454. processname:cat groupname:cat from_state:BACKOFF
  455. ``REMOTE_COMMUNICATION`` Event Type
  456. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  457. An event type raised when the ``supervisor.sendRemoteCommEvent()``
  458. method is called on Supervisor's RPC interface. The ``type`` and
  459. ``data`` are arguments of the RPC method.
  460. *Name*: ``REMOTE_COMMUNICATION``
  461. *Subtype Of*: ``EVENT``
  462. Body Description
  463. ++++++++++++++++
  464. .. code-block:: text
  465. type:type
  466. data
  467. ``PROCESS_LOG`` Event Type
  468. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  469. An event type emitted when a process writes to stdout or stderr. The
  470. event will only be emitted if the file descriptor is not in capture
  471. mode and if ``stdout_events_enabled`` or ``stderr_events_enabled``
  472. config options are set to ``true``. This event type is abstract, it
  473. will never be sent directly. Subscribing to this event type will
  474. cause a subscriber to receive event notifications for all subtypes of
  475. ``PROCESS_LOG``.
  476. *Name*: ``PROCESS_LOG``
  477. *Subtype Of*: ``EVENT``
  478. *Body Description*: N/A
  479. ``PROCESS_LOG_STDOUT`` Event Type
  480. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  481. Indicates a process has written to its stdout file descriptor. The
  482. event will only be emitted if the file descriptor is not in capture
  483. mode and if the ``stdout_events_enabled`` config option is set to
  484. ``true``.
  485. *Name*: ``PROCESS_LOG_STDOUT``
  486. *Subtype Of*: ``PROCESS_LOG``
  487. Body Description
  488. ++++++++++++++++
  489. .. code-block:: text
  490. processname:name groupname:name pid:pid
  491. data
  492. ``PROCESS_LOG_STDERR`` Event Type
  493. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  494. Indicates a process has written to its stderr file descriptor. The
  495. event will only be emitted if the file descriptor is not in capture
  496. mode and if the ``stderr_events_enabled`` config option is set to
  497. ``true``.
  498. *Name*: ``PROCESS_LOG_STDERR``
  499. *Subtype Of*: ``PROCESS_LOG``
  500. Body Description
  501. ++++++++++++++++
  502. .. code-block:: text
  503. processname:name groupname:name pid:pid
  504. data
  505. ``PROCESS_COMMUNICATION`` Event Type
  506. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  507. An event type raised when any process attempts to send information
  508. between ``<!--XSUPERVISOR:BEGIN-->`` and ``<!--XSUPERVISOR:END-->``
  509. tags in its output. This event type is abstract, it will never be
  510. sent directly. Subscribing to this event type will cause a subscriber
  511. to receive event notifications for all subtypes of
  512. ``PROCESS_COMMUNICATION``.
  513. *Name*: ``PROCESS_COMMUNICATION``
  514. *Subtype Of*: ``EVENT``
  515. *Body Description*: N/A
  516. ``PROCESS_COMMUNICATION_STDOUT`` Event Type
  517. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  518. Indicates a process has sent a message to Supervisor on its stdout
  519. file descriptor.
  520. *Name*: ``PROCESS_COMMUNICATION_STDOUT``
  521. *Subtype Of*: ``PROCESS_COMMUNICATION``
  522. Body Description
  523. ++++++++++++++++
  524. .. code-block:: text
  525. processname:name groupname:name pid:pid
  526. data
  527. ``PROCESS_COMMUNICATION_STDERR`` Event Type
  528. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  529. Indicates a process has sent a message to Supervisor on its stderr
  530. file descriptor.
  531. *Name*: ``PROCESS_COMMUNICATION_STDERR``
  532. *Subtype Of*: ``PROCESS_COMMUNICATION``
  533. Body Description
  534. ++++++++++++++++
  535. .. code-block:: text
  536. processname:name groupname:name pid:pid
  537. data
  538. ``SUPERVISOR_STATE_CHANGE`` Event Type
  539. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  540. An event type raised when the state of the :program:`supervisord`
  541. process changes. This type is abstract, it will never be sent
  542. directly. Subscribing to this event type will cause a subscriber to
  543. receive event notifications of all the subtypes of
  544. ``SUPERVISOR_STATE_CHANGE``.
  545. *Name*: ``SUPERVISOR_STATE_CHANGE``
  546. *Subtype Of*: ``EVENT``
  547. *Body Description*: N/A
  548. ``SUPERVISOR_STATE_CHANGE_RUNNING`` Event Type
  549. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  550. Indicates that :program:`supervisord` has started.
  551. *Name*: ``SUPERVISOR_STATE_CHANGE_RUNNING``
  552. *Subtype Of*: ``SUPERVISOR_STATE_CHANGE``
  553. *Body Description*: Empty string
  554. ``SUPERVISOR_STATE_CHANGE_STOPPING`` Event Type
  555. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  556. Indicates that :program:`supervisord` is stopping.
  557. *Name*: ``SUPERVISOR_STATE_CHANGE_STOPPING``
  558. *Subtype Of*: ``SUPERVISOR_STATE_CHANGE``
  559. *Body Description*: Empty string
  560. ``TICK`` Event Type
  561. ~~~~~~~~~~~~~~~~~~~
  562. An event type that may be subscribed to for event listeners to receive
  563. "wake-up" notifications every N seconds. This event type is abstract,
  564. it will never be sent directly. Subscribing to this event type will
  565. cause a subscriber to receive event notifications for all subtypes of
  566. ``TICK``.
  567. *Name*: ``TICK``
  568. *Subtype Of*: ``EVENT``
  569. *Body Description*: N/A
  570. ``TICK_5`` Event Type
  571. ~~~~~~~~~~~~~~~~~~~~~
  572. An event type that may be subscribed to for event listeners to receive
  573. "wake-up" notifications every 5 seconds.
  574. *Name*: ``TICK_5``
  575. *Subtype Of*: ``TICK``
  576. Body Description
  577. ++++++++++++++++
  578. This event type is a token set with a single key: "when", which
  579. indicates the epoch time for which the tick was sent.
  580. .. code-block:: text
  581. when:1201063880
  582. ``TICK_60`` Event Type
  583. ~~~~~~~~~~~~~~~~~~~~~~
  584. An event type that may be subscribed to for event listeners to receive
  585. "wake-up" notifications every 60 seconds.
  586. *Name*: ``TICK_60``
  587. *Subtype Of*: ``TICK``
  588. Body Description
  589. ++++++++++++++++
  590. This event type is a token set with a single key: "when", which
  591. indicates the epoch time for which the tick was sent.
  592. .. code-block:: text
  593. when:1201063880
  594. ``TICK_3600`` Event Type
  595. ~~~~~~~~~~~~~~~~~~~~~~~~
  596. An event type that may be subscribed to for event listeners to receive
  597. "wake-up" notifications every 3600 seconds (1 hour).
  598. *Name*: ``TICK_3600``
  599. *Subtype Of*: ``TICK``
  600. Body Description
  601. ++++++++++++++++
  602. This event type is a token set with a single key: "when", which
  603. indicates the epoch time for which the tick was sent.
  604. .. code-block:: text
  605. when:1201063880