1. Getting uWSGI + init.d playing nicely on Ubuntu 11.10

    A few weeks ago, I wanted to install uWSGI on my Ubuntu 11.10 box for http://allb.us.  After having gone through the standard aptitude/pip installs to get uwsgi installed, I noticed after running the init.d scripts, absolutely nothing would happen. 

    zip. nada. zilch.

    No log file + no uwsgi process == a lot of sad pandas.

    After having searched stackoverflow, it was quite apparent that I wasn’t the only unlucky soul to encounter this error.  To debug the uwsgi init.d script, I used the trusty set -xv trick atop to see the omgwtfbbqs.

    Here’s a few things I realized:

    1. The configuration file in /etc/uwsgi/apps-enabled must contain one of the recognized uwsgi configuration file extensions.  Initially, I symlinked my configuration file from the apps-available directory as allbus.  It didn’t like that at all.  I renamed the symlink to allbus.xml.
    2. The start-stop-daemon in the init.d script is being passed the location to the pid file via —pid-file instead of being told to create the pid file via the —make-pid-file option.  Thus, you need to make sure your uwsgi configuration file contains a directive to create the file at the same location the init.d script is looking for it.  *Note*: Take a look at the <pidfile> configuration.

    Here’s a gist I created of the xml uwsgi configuration I used for my Django application. Hopefully it helps save someone from the hour I spent in startup script hell. Enjoy! :D