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  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