I'm trying to configure an event listener for supervisord but can't get it to work.
I just want to listen for PROCESS_STATE changes and run some python code triggering an urllib2request.
In my .conf I have:
[eventlistener:statechanges]
command=python listener.py
events=PROCESS_STATE
And in listener.py:
def run(): runFunc() # Function to trigger an urllib2requestif __name__ == '__main__':run()
Then the trigger won't start, it just enters the FATAL state after some retries.
statechanges entered FATAL state, too many start retries too quickly
Any ideas or does someone have an example of how to write a listener for supervisord?
You can't just print random strings, supervisord listens at the stdout :)
How about this example from the docs:
import sysdef write_stdout(s):sys.stdout.write(s)sys.stdout.flush()def write_stderr(s):sys.stderr.write(s)sys.stderr.flush()def main():while 1:write_stdout('READY\n') # transition from ACKNOWLEDGED to READYline = sys.stdin.readline() # read header line from stdinwrite_stderr(line) # print it out to stderrheaders = dict([ x.split(':') for x in line.split() ])data = sys.stdin.read(int(headers['len'])) # read the event payloadwrite_stderr(data) # print the event payload to stderrwrite_stdout('RESULT 2\nOK') # transition from READY to ACKNOWLEDGEDif __name__ == '__main__':main()import sys
http://supervisord.org/events.html#example-event-listener-implementation