The Joy of Upstart

Upstart is a ridiculously easy way to turn your scripts into daemons. Take this python script:

/home/myuser/ez_daemon.py:

exec python /home/myuser/ez_daemon.py
And that&#8217;s it! <ul> <li>sudo start ez_daemon</li> <li>sudo tail -f /var/log/upstart/ez_daemon.log</li> <li>sudo stop ez_daemon</li> </ul> You can do this for any program, and it&#8217;s how Ubuntu and Fedora start most daemons. Here&#8217;s a more complete example:
author "Graham King <graham@gkgk.org>"
description "uwsgi server for example.com"

start on (static-network-up and started mysql)
stop on shutdown

console log
respawn
respawn limit 10 5

setuid www-data
setgid www-data

env PYTHONPATH=/srv/example/src/example/

exec /srv/example/bin/uwsgi \
--virtualenv=/srv/example/ \
--module=example.django_wsgi \
--http=127.0.0.1:8001
Each line is called a stanza, and they are documented in the Upstart cookbook. It’s clear, it’s easy, and it works. And that makes me happy.

Recent Insights

Optimize for Motivation

When your client is hundreds of miles away, but your bed only three feet, it helps …

What is SPDY?

This is HTTP A big friendly unsecured clear-text, line-oriented bear. This is SPDY A multi-plexed binary …

What is WebRTC?

WebRTC, short for Web Real Time Communications, is a specification and project adding JavaScript APIs in …