title: uWSGI works as process but not as daemon
body: <p>For my current flask deployment, I had to set up a uwsgi server.
  This is how I have created the uwsgi daemon:</p>
  
  <p><code>sudo vim /etc/init/uwsgi.conf</code></p>
  
  <pre><code># file: /etc/init/uwsgi.conf
  description "uWSGI server"
  
  start on runlevel [2345]
  stop on runlevel [!2345]
  respawn
  
  exec /myproject/myproject-env/bin/uwsgi --uid www-data --gid www-data --home /myproject/myproject-env/site/F11/Engineering/  --socket /tmp/uwsgi.sock --chmod-socket --module F11 --callable app --pythonpath /myproject/myproject-env/site/F11/Engineering/ -H /myproject/myproject-env
  </code></pre>
  
  <p>However after running this successfully: <code>sudo start uwsgi</code></p>
  
  <pre><code>uwsgi start/running, process 1286
  </code></pre>
  
  <p>And trying to access the application via browser:</p>
  
  <p>I get a <strong>502 Bad Gateway</strong></p>
  
  <p>and an error entry in nginx error.log:</p>
  
  <blockquote>
    <p>2013/06/13 23:47:28 [error] 743#0: *296 upstream prematurely closed
    connection while reading response header from upstream, client:
    xx.161.xx.228, server: myproject.com, request: "GET /show_records/2013/6 HTTP/1.1", upstream:
    "uwsgi://unix:///tmp/uwsgi.sock:", host: "myproject.com"</p>
  </blockquote>
  
  <p>But the sock file has the permission it needs:</p>
  
  <pre><code>srw-rw-rw- 1 www-data www-data 0 Jun 13 23:46 /tmp/uwsgi.sock
  </code></pre>
  
  <p>If I run the <code>exec</code> command from above in the command line as a process, it works perfectly fine.  Why is the daemon not working correctly please?</p>
  
  <p>btw Nginx is running as 
  <code>vim /etc/nginx/nginx.conf</code></p>
  
  <pre><code>user www-data;
  </code></pre>
  
  <p>and <code>vim /etc/nginx/sites-available/default</code></p>
  
  <pre><code>location / {
                  uwsgi_pass   unix:///tmp/uwsgi.sock;
                  include        uwsgi_params;
          }
  </code></pre>
  
  <p>and it is started as <code>sudo service nginx start</code></p>
  
  <p>I am running this on <code>Ubuntu 12.04 LTS</code>.</p>
  
  <p>I hope I have provided all the necessary data, hope someone can guide me into the right direction. Thanks.</p>