events.rst 30 KB

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