Supervisor/supervisor

Event Listener is acting like a program and is getting triggered right away and not listening for any events

siva54 opened this issue · 3 comments

siva54 commented

I need help with an use case. I have two processes that I need to start using supervisord. These two processes should be sequential, as the 2nd process is dependent on the 1st process. Since supervisor, there is no means to do sequential execution. I'm using an event listener that should listen to process starting for 1st process (2nd process autostart is set to false), and then start 2nd processor using supervisorctl.

However, the problem I'm facing is that the event listener is starting as a program and not as an event listener. It's not listening to events and just running directly. Also, one more point noted is that the stdin input doesn't come to this event listener script, So I'm not able to track and write if conditions on what is the event. Here's an example of how I'm doing this,

[eventlistener:start_2ndprocess]
command=/usr/src/app/event_listener.sh
events=PROCESS_STATE_RUNNING

Please help.

However, the problem I'm facing is that the event listener is starting as a program and not as an event listener. It's not listening to events and just running directly.

The name [eventlistener:start_2ndprocess] will cause supervisord to treat it as an eventlistener. The only way supervisord will treat it as a program is if the section is called [program:start_2ndprocess].

Also, one more point noted is that the stdin input doesn't come to this event listener script,

Please see this page for detailed information about how eventlisteners work:
http://supervisord.org/events.html

When an eventlistener starts, supervisord puts it into the ACKNOWLEDGED state as described on the page linked above. The eventlistener must send READY\n to its stdout file descriptor to tell supervisord that it is ready to receive events on its stdin file descriptor. supervisord will not send any events until it sees READY\n.

It may be helpful to set loglevel=debug in the [supervisord] section of the config file. This will show debug messages related to the eventlistener protocol. However, it will not show anything until the eventlistener first sends READY\n.

siva54 commented

Thank you, @mnaberez, It clears up my confusion.

Another thing I'm seeing is, event listener is listening to its own events. How do I have this to listen to other process's events.

When an eventlistener is subscribed to an event type, it will receive that event for all processes running under supervisord. The event payload will contain the name of the process that triggered the event.

The eventlistener will have an environment variable named SUPERVISOR_PROCESS_NAME with its own name.