Using Supervisor with Upstart

In the previous post where we managed our node.js server with supervisor, we used a classic init script to have supervisor start on reboot. In this receipe, we’ll instead use upstart, a replacement for init bundled with Ubuntu distributions.

stop and remove the old supervisord script

Previously, we created this file in our home directory, so you might still have that first copy in case you want to go back doing it the old-fashioned way 🙂

$ sudo /etc/init.d/supervisord stop
$ sudo rm /etc/init.d/supervisord

create an upstart script

Create a new file /etc/init/supervisor.conf. Its content should look like this:

description     "supervisor"

start on runlevel [2345]
stop on runlevel [!2345]

respawn

exec /usr/local/bin/supervisord --nodaemon --configuration /etc/supervisord.conf

Note that we’re using the same supervisord configuration file we used before. No changes there…

here’s the gotcha!

This upstart script is modified from one found at lincoln loop. The problem with using ‘supervisord.conf’ as the upstart script filename is that the command supervisorctl picks that up and attempt to use it as a supervisor configuration file, which it is NOT. By changing the upstart script and service description to simply supervisor sans ‘d’, we can use supervisorctl normally.

using supervisord with upstart

We can now start and stop supervisord with the following commands

$ sudo stop supervisor
$ sudo start supervisor

To check the status of supervisor

$ initctl list
$ initctl status supervisor

2 comments on “Using Supervisor with Upstart

  1. Thanks for the article. I happened upon yours and Lincoln Loop’s articles via the same Google search, IIRC. Both were helpful. I’ve been working on the “master” deployment strategy, for ease of management (I lack the proper Linux skills to continually hack and check on processes, etc.).

Leave a Reply