Managing Monit with Upstart
I just moved my production server from a Centos 4.6 VPS to Ubuntu 10.04. I had been quite happy with the Centos – but I’ve discovered Ubuntu is far nicer. The packages are more up to date and it feels like considerably more thought has gone into it.
Ubuntu uses Upstart to manage its services. While Upstart is excellent at starting services and keeping them up, it has limited ability to restart services when they grow too big for their boots. Furthermore, not every service has been moved over to Upstart’s management; some – in particular Apache – are still managed the legacy
So we need another process manager.
I like monit. It solves the Apache problem and the proactive-restart problem, but now we need to manage Monit itself. Upstart is the future so we’ll use that.
First we disengage
$ sudo /etc/init.d/monit stop $ sudo update-rc.d -f monit remove
Now we configure an Upstart job in
start on runlevel  stop on runlevel  respawn exec /usr/local/bin/monit -Ic /etc/monit/monitrc
N.B. I’m not sure whether the stop runlevels should include
Next we edit
/etc/default/monit and change
startup=1. (I’m not sure whether this is necessary but it doesn’t hurt.)
Finally we activate Upstart:
$ sudo start monit
We can use Monit to manage services which Upstart doesn’t yet manage, and Upstart to manage Monit. And Monit can cut tall poppies down to size whenever needed.
Hopefully in due course Upstart will encompass all of the above. In the meantime this works for me.