events.rst 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893
  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. sys.stdout.write(s)
  249. sys.stdout.flush()
  250. def write_stderr(s):
  251. sys.stderr.write(s)
  252. sys.stderr.flush()
  253. def main():
  254. while 1:
  255. write_stdout('READY\n') # transition from ACKNOWLEDGED to READY
  256. line = sys.stdin.readline() # read header line from stdin
  257. write_stderr(line) # print it out to stderr
  258. headers = dict([ x.split(':') for x in line.split() ])
  259. data = sys.stdin.read(int(headers['len'])) # read the event payload
  260. write_stderr(data) # print the event payload to stderr
  261. write_stdout('RESULT 2\nOK') # transition from READY to ACKNOWLEDGED
  262. if __name__ == '__main__':
  263. main()
  264. import sys
  265. Other sample event listeners are present within the :term:`superlance`
  266. package, including one which can monitor supervisor subprocesses and
  267. restart a process if it is using "too much" memory.
  268. Event Listener Error Conditions
  269. +++++++++++++++++++++++++++++++
  270. If the event listener process dies while the event is being
  271. transmitted to its stdin, or if it dies before sending an result
  272. structure back to supervisord, the event is assumed to not be
  273. processed and will be rebuffered by supervisord and sent again later.
  274. If an event listener sends data to its stdout which supervisor does
  275. not recognize as an appropriate response based on the state that the
  276. event listener is in, the event listener will be placed into the
  277. ``UNKNOWN`` state, and no further event notifications will be sent to
  278. it. If an event was being processed by the listener during this time,
  279. it will be rebuffered and sent again later.
  280. Miscellaneous
  281. +++++++++++++
  282. Event listeners may use the Supervisor XML-RPC interface to call "back
  283. in" to Supervisor. As such, event listeners can impact the state of a
  284. Supervisor subprocess as a result of receiving an event notification.
  285. For example, you may want to generate an event every few minutes
  286. related to process usage of Supervisor-controlled subprocesses, and if
  287. any of those processes exceed some memory threshold, you would like
  288. to restart it. You would write a program that caused supervisor to
  289. generate ``PROCESS_COMMUNICATION`` events every so often with memory
  290. information in them, and an event listener to perform an action based
  291. on processing the data it receives from these events.
  292. .. _event_types:
  293. Event Types
  294. -----------
  295. The event types are a controlled set, defined by Supervisor itself.
  296. There is no way to add an event type without changing
  297. :program:`supervisord` itself. This is typically not a problem,
  298. though, because metadata is attached to events that can be used by
  299. event listeners as additional filter criterion, in conjunction with
  300. its type.
  301. Event types that may be subscribed to by event listeners are
  302. predefined by supervisor and fall into several major categories,
  303. including "process state change", "process communication", and
  304. "supervisor state change" events. Below are tables describing
  305. these event types.
  306. In the below list, we indicate that some event types have a "body"
  307. which is a a *token set*. A token set consists of a set of charaters
  308. with space-separated tokens. Each token represents a key-value pair.
  309. The key and value are separated by a colon. For example:
  310. .. code-block:: text
  311. processname:cat groupname:cat from_state:STOPPED
  312. Token sets do not have a linefeed or carriage return character at
  313. their end.
  314. ``EVENT`` Event Type
  315. ~~~~~~~~~~~~~~~~~~~~
  316. The base event type. This event type is abstract. It will never be
  317. sent directly. Subscribing to this event type will cause a subscriber
  318. to receive all event notifications emitted by Supervisor.
  319. *Name*: ``EVENT``
  320. *Subtype Of*: N/A
  321. *Body Description*: N/A
  322. ``PROCESS_STATE`` Event Type
  323. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  324. This process type indicates a process has moved from one state to
  325. another. See :ref:`process_states` for a description of the states
  326. that a process moves through during its lifetime. This event type is
  327. abstract, it will never be sent directly. Subscribing to this event
  328. type will cause a subscriber to receive event notifications of all the
  329. event types that are subtypes of ``PROCESS_STATE``.
  330. *Name*: ``PROCESS_STATE``
  331. *Subtype Of*: ``EVENT``
  332. Body Description
  333. ++++++++++++++++
  334. All subtypes of ``PROCESS_STATE`` have a body which is a token set.
  335. Additionally, each ``PROCESS_STATE`` subtype's token set has a default
  336. set of key/value pairs: ``processname``, ``groupname``, and
  337. ``from_state``. ``processname`` represents the process name which
  338. supervisor knows this process as. ``groupname`` represents the name of
  339. the supervisord group which this process is in. ``from_state`` is the
  340. name of the state from which this process is transitioning (the new
  341. state is implied by the concrete event type). Concrete subtypes may
  342. include additional key/value pairs in the token set.
  343. ``PROCESS_STATE_STARTING`` Event Type
  344. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  345. Indicates a process has moved from a state to the STARTING state.
  346. *Name*: ``PROCESS_STATE_STARTING``
  347. *Subtype Of*: ``PROCESS_STATE``
  348. Body Description
  349. ++++++++++++++++
  350. This body is a token set. It has the default set of key/value pairs
  351. plus an additional ``tries`` key. ``tries`` represents the number of
  352. times this process has entered this state before transitioning to
  353. RUNNING or FATAL (it will never be larger than the "startretries"
  354. parameter of the process). For example:
  355. .. code-block:: text
  356. processname:cat groupname:cat from_state:STOPPED tries:0
  357. ``PROCESS_STATE_RUNNING`` Event Type
  358. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  359. Indicates a process has moved from the ``STARTING`` state to the
  360. ``RUNNING`` state. This means that the process has successfully
  361. started as far as Supervisor is concerned.
  362. *Name*: ``PROCESS_STATE_RUNNING``
  363. *Subtype Of*: ``PROCESS_STATE``
  364. Body Description
  365. ++++++++++++++++
  366. This body is a token set. It has the default set of key/value pairs
  367. plus an additional ``pid`` key. <code>pid</code> represents the UNIX
  368. process id of the process that was started. For example:
  369. .. code-block:: text
  370. processname:cat groupname:cat from_state:STARTING pid:2766
  371. ``PROCESS_STATE_BACKOFF`` Event Type
  372. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  373. Indicates a process has moved from the ``STARTING`` state to the
  374. ``BACKOFF`` state. This means that the process did not successfully
  375. enter the RUNNING state, and Supervisor is going to try to restart it
  376. unless it has exceeded its "startretries" configuration limit.
  377. *Name*: ``PROCESS_STATE_BACKOFF``
  378. *Subtype Of*: ``PROCESS_STATE``
  379. Body Description
  380. ++++++++++++++++
  381. This body is a token set. It has the default set of key/value pairs
  382. plus an additional ``tries`` key. ``tries`` represents the number of
  383. times this process has entered this state before transitioning to
  384. ``RUNNING`` or ``FATAL`` (it will never be larger than the
  385. "startretries" parameter of the process). For example:
  386. .. code-block:: text
  387. processname:cat groupname:cat from_state:STOPPED tries:0
  388. ``PROCESS_STATE_STOPPING`` Event Type
  389. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  390. Indicates a process has moved from either the ``RUNNING`` state or the
  391. ``STARTING`` state to the ``STOPPING`` state.
  392. *Name*: ``PROCESS_STATE_STOPPING``
  393. *Subtype Of*: ``PROCESS_STATE``
  394. Body Description
  395. ++++++++++++++++
  396. This body is a token set. It has the default set of key/value pairs
  397. plus an additional ``pid`` key. ``pid`` represents the UNIX process
  398. id of the process that was started. For example:
  399. .. code-block:: text
  400. processname:cat groupname:cat from_state:STARTING pid:2766
  401. ``PROCESS_STATE_EXITED`` Event Type
  402. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  403. Indicates a process has moved from the ``RUNNING`` state to the
  404. ``EXITED`` state.
  405. *Name*: ``PROCESS_STATE_EXITED``
  406. *Subtype Of*: ``PROCESS_STATE``
  407. Body Description
  408. ++++++++++++++++
  409. This body is a token set. It has the default set of key/value pairs
  410. plus two additional keys: ``pid`` and ``expected``. ``pid``
  411. represents the UNIX process id of the process that exited.
  412. ``expected`` represents whether the process exited with an expected
  413. exit code or not. It will be ``0`` if the exit code was unexpected,
  414. or ``1`` if the exit code was expected. For example:
  415. .. code-block:: text
  416. processname:cat groupname:cat from_state:RUNNING expected:0 pid:2766
  417. ``PROCESS_STATE_STOPPED`` Event Type
  418. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  419. Indicates a process has moved from the ``STOPPING`` state to the
  420. ``STOPPED`` state.
  421. *Name*: ``PROCESS_STATE_STOPPED``
  422. *Subtype Of*: ``PROCESS_STATE``
  423. Body Description
  424. ++++++++++++++++
  425. This body is a token set. It has the default set of key/value pairs
  426. plus an additional ``pid`` key. ``pid`` represents the UNIX process
  427. id of the process that was started. For example:
  428. .. code-block:: text
  429. processname:cat groupname:cat from_state:STOPPING pid:2766
  430. ``PROCESS_STATE_FATAL`` Event Type
  431. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  432. Indicates a process has moved from the ``BACKOFF`` state to the
  433. ``FATAL`` state. This means that Supervisor tried ``startretries``
  434. number of times unsuccessfully to start the process, and gave up
  435. attempting to restart it.
  436. *Name*: ``PROCESS_STATE_FATAL``
  437. *Subtype Of*: ``PROCESS_STATE``
  438. Body Description
  439. ++++++++++++++++
  440. This event type is a token set with the default key/value pairs. For
  441. example:
  442. .. code-block:: text
  443. processname:cat groupname:cat from_state:BACKOFF
  444. ``PROCESS_STATE_UNKNOWN`` Event Type
  445. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  446. Indicates a process has moved from any state to the ``UNKNOWN`` state
  447. (indicates an error in :program:`supervisord`). This state transition
  448. will only happen if :program:`supervisord` itself has a programming
  449. error.
  450. *Name*: ``PROCESS_STATE_UNKNOWN``
  451. *Subtype Of*: ``PROCESS_STATE``
  452. Body Description
  453. ++++++++++++++++
  454. This event type is a token set with the default key/value pairs. For
  455. example:
  456. .. code-block:: text
  457. processname:cat groupname:cat from_state:BACKOFF
  458. ``REMOTE_COMMUNICATION`` Event Type
  459. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  460. An event type raised when the ``supervisor.sendRemoteCommEvent()``
  461. method is called on Supervisor's RPC interface. The ``type`` and
  462. ``data`` are arguments of the RPC method.
  463. *Name*: ``REMOTE_COMMUNICATION``
  464. *Subtype Of*: ``EVENT``
  465. Body Description
  466. ++++++++++++++++
  467. .. code-block:: text
  468. type:type
  469. data
  470. ``PROCESS_LOG`` Event Type
  471. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  472. An event type emitted when a process writes to stdout or stderr. The
  473. event will only be emitted if the file descriptor is not in capture
  474. mode and if ``stdout_events_enabled`` or ``stderr_events_enabled``
  475. config options are set to ``true``. This event type is abstract, it
  476. will never be sent directly. Subscribing to this event type will
  477. cause a subscriber to receive event notifications for all subtypes of
  478. ``PROCESS_LOG``.
  479. *Name*: ``PROCESS_LOG``
  480. *Subtype Of*: ``EVENT``
  481. *Body Description*: N/A
  482. ``PROCESS_LOG_STDOUT`` Event Type
  483. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  484. Indicates a process has written to its stdout file descriptor. The
  485. event will only be emitted if the file descriptor is not in capture
  486. mode and if the ``stdout_events_enabled`` config option is set to
  487. ``true``.
  488. *Name*: ``PROCESS_LOG_STDOUT``
  489. *Subtype Of*: ``PROCESS_LOG``
  490. Body Description
  491. ++++++++++++++++
  492. .. code-block:: text
  493. processname:name groupname:name pid:pid
  494. data
  495. ``PROCESS_LOG_STDERR`` Event Type
  496. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  497. Indicates a process has written to its stderr file descriptor. The
  498. event will only be emitted if the file descriptor is not in capture
  499. mode and if the ``stderr_events_enabled`` config option is set to
  500. ``true``.
  501. *Name*: ``PROCESS_LOG_STDERR``
  502. *Subtype Of*: ``PROCESS_LOG``
  503. Body Description
  504. ++++++++++++++++
  505. .. code-block:: text
  506. processname:name groupname:name pid:pid
  507. data
  508. ``PROCESS_COMMUNICATION`` Event Type
  509. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  510. An event type raised when any process attempts to send information
  511. between ``<!--XSUPERVISOR:BEGIN-->`` and ``<!--XSUPERVISOR:END-->``
  512. tags in its output. This event type is abstract, it will never be
  513. sent directly. Subscribing to this event type will cause a subscriber
  514. to receive event notifications for all subtypes of
  515. ``PROCESS_COMMUNICATION``.
  516. *Name*: ``PROCESS_COMMUNICATION``
  517. *Subtype Of*: ``EVENT``
  518. *Body Description*: N/A
  519. ``PROCESS_COMMUNICATION_STDOUT`` Event Type
  520. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  521. Indicates a process has sent a message to Supervisor on its stdout
  522. file descriptor.
  523. *Name*: ``PROCESS_COMMUNICATION_STDOUT``
  524. *Subtype Of*: ``PROCESS_COMMUNICATION``
  525. Body Description
  526. ++++++++++++++++
  527. .. code-block:: text
  528. processname:name groupname:name pid:pid
  529. data
  530. ``PROCESS_COMMUNICATION_STDERR`` Event Type
  531. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  532. Indicates a process has sent a message to Supervisor on its stderr
  533. file descriptor.
  534. *Name*: ``PROCESS_COMMUNICATION_STDERR``
  535. *Subtype Of*: ``PROCESS_COMMUNICATION``
  536. Body Description
  537. ++++++++++++++++
  538. .. code-block:: text
  539. processname:name groupname:name pid:pid
  540. data
  541. ``SUPERVISOR_STATE_CHANGE`` Event Type
  542. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  543. An event type raised when the state of the :program:`supervisord`
  544. process changes. This type is abstract, it will never be sent
  545. directly. Subscribing to this event type will cause a subscriber to
  546. receive event notifications of all the subtypes of
  547. ``SUPERVISOR_STATE_CHANGE``.
  548. *Name*: ``SUPERVISOR_STATE_CHANGE``
  549. *Subtype Of*: ``EVENT``
  550. *Body Description*: N/A
  551. ``SUPERVISOR_STATE_CHANGE_RUNNING`` Event Type
  552. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  553. Indicates that :program:`supervisord` has started.
  554. *Name*: ``SUPERVISOR_STATE_CHANGE_RUNNING``
  555. *Subtype Of*: ``SUPERVISOR_STATE_CHANGE``
  556. *Body Description*: Empty string
  557. ``SUPERVISOR_STATE_CHANGE_STOPPING`` Event Type
  558. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  559. Indicates that :program:`supervisord` is stopping.
  560. *Name*: ``SUPERVISOR_STATE_CHANGE_STOPPING``
  561. *Subtype Of*: ``SUPERVISOR_STATE_CHANGE``
  562. *Body Description*: Empty string
  563. ``TICK`` Event Type
  564. ~~~~~~~~~~~~~~~~~~~
  565. An event type that may be subscribed to for event listeners to receive
  566. "wake-up" notifications every N seconds. This event type is abstract,
  567. it will never be sent directly. Subscribing to this event type will
  568. cause a subscriber to receive event notifications for all subtypes of
  569. ``TICK``.
  570. Note that the only ``TICK`` events available are the ones listed below.
  571. You cannot subscribe to an arbitrary ``TICK`` interval. If you need an
  572. interval not provided below, you can subscribe to one of the shorter
  573. intervals given below and keep track of the time between runs in your
  574. event listener.
  575. *Name*: ``TICK``
  576. *Subtype Of*: ``EVENT``
  577. *Body Description*: N/A
  578. ``TICK_5`` Event Type
  579. ~~~~~~~~~~~~~~~~~~~~~
  580. An event type that may be subscribed to for event listeners to receive
  581. "wake-up" notifications every 5 seconds.
  582. *Name*: ``TICK_5``
  583. *Subtype Of*: ``TICK``
  584. Body Description
  585. ++++++++++++++++
  586. This event type is a token set with a single key: "when", which
  587. indicates the epoch time for which the tick was sent.
  588. .. code-block:: text
  589. when:1201063880
  590. ``TICK_60`` Event Type
  591. ~~~~~~~~~~~~~~~~~~~~~~
  592. An event type that may be subscribed to for event listeners to receive
  593. "wake-up" notifications every 60 seconds.
  594. *Name*: ``TICK_60``
  595. *Subtype Of*: ``TICK``
  596. Body Description
  597. ++++++++++++++++
  598. This event type is a token set with a single key: "when", which
  599. indicates the epoch time for which the tick was sent.
  600. .. code-block:: text
  601. when:1201063880
  602. ``TICK_3600`` Event Type
  603. ~~~~~~~~~~~~~~~~~~~~~~~~
  604. An event type that may be subscribed to for event listeners to receive
  605. "wake-up" notifications every 3600 seconds (1 hour).
  606. *Name*: ``TICK_3600``
  607. *Subtype Of*: ``TICK``
  608. Body Description
  609. ++++++++++++++++
  610. This event type is a token set with a single key: "when", which
  611. indicates the epoch time for which the tick was sent.
  612. .. code-block:: text
  613. when:1201063880
  614. ``PROCESS_GROUP`` Event Type
  615. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  616. An event type raised when a process group is added to or removed from
  617. Supervisor. This type is abstract, it will never be sent
  618. directly. Subscribing to this event type will cause a subscriber to
  619. receive event notifications of all the subtypes of
  620. ``PROCESS_GROUP``.
  621. *Name*: ``PROCESS_GROUP``
  622. *Subtype Of*: ``EVENT``
  623. *Body Description*: N/A
  624. ``PROCESS_GROUP_ADDED`` Event Type
  625. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  626. Indicates that a process group has been added to Supervisor's configuration.
  627. *Name*: ``PROCESS_GROUP_ADDED``
  628. *Subtype Of*: ``PROCESS_GROUP``
  629. *Body Description*: This body is a token set with just a groupname key/value.
  630. .. code-block:: text
  631. groupname:cat
  632. ``PROCESS_GROUP_REMOVED`` Event Type
  633. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  634. Indicates that a process group has been removed from Supervisor's configuration.
  635. *Name*: ``PROCESS_GROUP_REMOVED``
  636. *Subtype Of*: ``PROCESS_GROUP``
  637. *Body Description*: This body is a token set with just a groupname key/value.
  638. .. code-block:: text
  639. groupname:cat