Have Supervisord Periodically restart child processes

dm03514 picture dm03514 · Sep 24, 2012 · Viewed 17.5k times · Source

I am using Supervisor (3.0a12) on ubuntu 12.04 to manage php gearman workers. Sometimes the workers get caught in a weird state where they use tons of cpu and ram. While I am figuring this issue out I thought it would be nice to have Supervisor automatically kill and refresh workers occasionally. I looked at http://supervisord.org/configuration.html the configuration documentation and didn't seem to see any options that would allow for this.

Does anyone know if it is possible to have supervisord periodically restart all processes it governs??

Answer

scum picture scum · Jul 27, 2013

You could use crontab to pass commands directly to supervisorctl. For example, the following will restart a process every 20 minutes.

0,20,40 * * * * /path/to/supervisorctl restart [supervisor_process]