Sorry this page looks weird. It was automatically migrated from my old blog, which had a different layout and different CSS.

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 init.d way.

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 init.d:

$ sudo /etc/init.d/monit stop
$ sudo update-rc.d -f monit remove

Now we configure an Upstart job in /etc/init/monit.conf:

start on runlevel [2345]
stop on runlevel [06]
exec /usr/local/bin/monit -Ic /etc/monit/monitrc

N.B. I’m not sure whether the stop runlevels should include 1.

Next we edit /etc/default/monit and change startup=0 to 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.

Andrew Stewart • 21 November 2011 • Deployment
You can reach me by email or on Twitter.