How can I configure supervisord managed program to wait X secs before attemting to restart?
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:
I needed a simple way to run a command from inside a docker container, where there is no cron. Here is what I'm using:
[program:runevery] directory = /my/workdir command = sh -c "sleep 5;date >>/root/test.ts" stdout_logfile = /var/log/supervisor/%(program_name)s.log stderr_logfile = /var/log/supervisor/%(program_name)s.log autorestart = true startsecs = 0 exitcodes = 0,1,2
startsecs = 0 ensures that supervisor thinks the command was started successfully even if it exits after a few secs. Otherwise supervisor will stop restarting it, thinking it's in a loop.
Here is what you would see in /root/date.ts with the example above:
# tail -f /root/test.ts Tue Nov 17 20:42:58 UTC 2015 Tue Nov 17 20:43:04 UTC 2015 Tue Nov 17 20:43:10 UTC 2015 [...]
Tune the sleep to your liking and replace 'date >>/root/test.ts' with whatever you need.
This solution also comes handy if you need to run a cronjob more often than every minute.