Event Listeners and Event Notifications

Supervisor provides a way for a specially written program (which itruns as a subprocess) called an “event listener” to subscribe to“event notifications”. An event notification implies that somethinghappened related to a subprocess controlled by supervisordor to supervisord itself. Event notifications are groupedinto types in order to make it possible for event listeners tosubscribe to a limited subset of event notifications. Supervisorcontinually emits event notifications as its running even if there areno listeners configured. If a listener is configured and subscribedto an event type that is emitted during a supervisordlifetime, that listener will be notified.

The purpose of the event notification/subscription system is toprovide a mechanism for arbitrary code to be run (e.g. send an email,make an HTTP request, etc) when some condition is met. That conditionusually has to do with subprocess state. For instance, you may wantto notify someone via email when a process crashes and is restarted bySupervisor.

The event notification protocol is based on communication via asubprocess’ stdin and stdout. Supervisor sends specially-formattedinput to an event listener process’ stdin and expectsspecially-formatted output from an event listener’s stdout, forming arequest-response cycle. A protocol agreed upon between supervisor andthe listener’s implementer allows listeners to process eventnotifications. Event listeners can be written in any languagesupported by the platform you’re using to run Supervisor. Althoughevent listeners may be written in any language, there is speciallibrary support for Python in the form of asupervisor.childutils module, which makes creating eventlisteners in Python slightly easier than in other languages.