For applications that need to run forever, supervisord is awesome. It can monitor processes and automatically restart them if necessary. In addition, it can also provide log rotating and so much more. There's more to it, of course. Google is your friend.
Anyways, start by grabbing easy_install which will be used to get
supervisord (credits to SaltyCrane Blog for the source:
$ sudo apt-get install python-pip python-dev build-essential $ sudo pip install --upgrade pip $ sudo pip install --upgrade virtualenv
Now, get supervisord (for more detailed docs on installation, checkout the source here):
Check your installation, the following command should output a bunch of text:
Create a configuration file:
echo_supervisord_conf > /etc/supervisord.conf
Add this to the end:
We are effectively creating a
supervisord will manage.
supervisord (for official documentation, see here:
supervisord -c /etc/supervisord.conf
supervisorctl allows you to manipulate processes managed by
supervisord. Check the current processes:
$ supervisorctl status all
Stop or start all processes (substitute the content within the  with the following options):
$ supervisorctl [stop|start] [<program name>|all]
Notes and Extras
supervisordis a process and thus must be managed by some kind of init.d bootup script like Upstart. Google is your friend.
Here's a slightly more sophisticated
[program:yousosalty] command=/var/www/yousosalty/yousosalty autostart=true autorestart=true startretries=100 directory=/var/www/yousosalty
program definition for my side project, You So Salty.
program definition for a ghost blog:
[program:ghost] command=node /var/www/ghost/index.js autostart=true autorestart=true startretries=100 directory=/var/www/ghost user = ghost stdout_logfile = /var/log/supervisor/ghost.log stderr_logfile = /var/log/supervisor/ghost_err.log environment = NODE_ENV="production"