How to configure supervisord managed program to wait X secs before attemting to restart

supervisordworker-process

I've got a worker process which processes 1 RabbitMq message at a time. Right now, as soon as the worker exits, supervisord is restarting it (which will process the next message).

I'd like to set an interval X seconds, so that supervisord does not restart immidietly, but it waits a given amount of time before starting another worker.

Is this possible? How?

Best Answer

There is no way to specify interval in supervisor program section, but what you could do is put "sleep()" into your code so that after program waits for specified period of time after it finishes with message processing.

If you don't want/cant alter the program code, you may try wrapping it into bash script, for example:

#!/bin/bash
/usr/local/bin/myprogram
sleep 30

And alter your supervisor program section to run that script, instead of your program:

command=/usr/local/bin/myprogram.sh