# 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 <a href="http://allb.us">http://allb.us</a>.  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 <a href="http://stackoverflow.com">stackoverflow</a>, it was quite apparent that I wasn't the only <a href="http://serverfault.com/questions/208079/cant-start-uwsgi-in-ubuntu-10-10">unlucky</a> soul to encounter this error.  To debug the uwsgi init.d script, I used the trusty <a href="http://linux.101hacks.com/bash-scripting/debug-a-shell-script/">set -xv trick</a> atop to see the omgwtfbbqs.

Here's a few things I realized:

  - 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.  <strong>It didn't like that at all</strong>.  I renamed the symlink to allbus.xml.
  - 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.  <strong>*Note*</strong>: Take a look at the &lt;pidfile&gt; 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

<script src="https://gist.github.com/1721819.js"></script></p>

