Long-running or continuously running processes with Supervisord

Came across this program while reading a friend’s blog post. This is essentially a process manager designed to manage long-running or continuously-running processes.

I happened to be working on a cli script / background process at work that I needed to have running continuously. My initial idea would have been to use cron to kickoff the process, and then either:

a) Keep it running with an infinite loop or

b) Schedule the cron entry to have the script fire every minute, and use some kind of lockfile mechanism to prevent overlapping

These options can work, but they both present problems in terms of process interruptions. What happens on server or system restart? What about db outages that cause the process to fail?

Supervisord is nice because it allows you to deploy event listener scripts that fire when a managed process’s status changes. For example, I could write a script to send a notification e-mail if a process’s status changes to STOPPED. It also provides a nice little web UI to check status / stop / start a process, and even monitor output in real-time.

Check it out at http://supervisord.org/