Supervisord

Supervisord or Supervisor daemon is an open source process management system. In a nutshell: if a process crashes for any reason, Supervisor restarts it. From the Supervisord website:

Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems.

It shares some of the same goals of programs like launchd, daemontools, and runit. Unlike some of these programs, it is not meant to be run as a substitute for init as “process id 1”. Instead it is meant to be used to control processes related to a project or a customer, and is meant to start like any other program at boot time.

Agile uses Supervisor to monitor the PediaPress PDF server tools on this wiki, and to monitor modelr-server on its EC2 instance.

Installing
sudo pip install supervisord

Setting up
Supervisor itself can generate its config file:

sudo echo_supervisord_conf > /etc/supervisord.conf sudo vi /etc/supervisord

Make the necessary changes. For example, for Collection setup:


 * 1) Change the server name from 127.0.0.1 to * and add this:
 * 2) Then add the programs to supervise:
 * PDF RENDERSERVER - MEDIAWIKI COLLECTION EXTENSION

[program:qserve] command = mw-qserve

[program:nserve] command = nserve

[program:nslave] command = nslave --cachedir /var/cache/mwlib

[program:postman] command = postman --cachedir /var/cache/mwlib

...on Ubuntu
Grab supervisord.init:

Make sure the service executable is owned and executable by root: sudo chown root:root /etc/init.d/supervisord sudo chmod 775 /etc/init.d/supervisord

Then start the service: sudo /etc/init.d/supervisord start

...on RedHat Linux
Use chkconfig:

First, set it up for service management, so it comes up at reboot: sudo cp ~/supervisord.init_redhat /etc/rc.d/init.d/supervisord sudo cp ~/supervisord.sysconfig_redhat /etc/sysconfig/supervisord

Make sure nothing is running with, then kill if they are.

Then add the service: sudo chkconfig --add supervisord

Then start the service: sudo service supervisord start

And turn it on: sudo chkconfig supervisord on

Bounce the server to make sure.

...on other systems
See their various init scripts.