title: failed to find application 'wsgi' when launching upstart script
body: <p>I'm trying to deploy a web app written using Flask onto an Ubuntu based VPS (hosted on Digital Ocean). I've run into an issue in the final steps of deployment.</p>
  
  <p>Following <a href="https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-14-04" rel="nofollow">this guide</a> I've gotten through everything up to the Upstart script where the project fails completely.</p>
  
  <p>Looking in the log file after I <code>sudo start myproject</code> I found one line that reads: <code>Failed to find application 'wsgi'</code></p>
  
  <p>Folder Structure:</p>
  
  <pre><code>myproject
  - venv
  - templates
  - static
  - wsgi.py
  - main.py
  </code></pre>
  
  <p>The wsgi.py is:</p>
  
  <pre><code>from main import app
  
  if __name__ == "__main__":
      app.run()
  </code></pre>
  
  <p>Finally, the Upstart file is currently:</p>
  
  <pre><code>start on runlevel [2345]
  stop on runlevel [!2345]
  
  respawn
  setuid myuseraccount
  setgid www-data
  
  env PATH=/var/www/myproject/venv/bin
  chdir /var/www/myproject
  
  exec gunicorn --workers 2 --bind unix:myproject.sock -m 007 wsgi:app
  </code></pre>
  
  <p>I've sent a lot of time trying to troubleshoot,but I am lost. Everything works properly when I start the project using <code>gunicorn --bind 0.0.0.0:8000 wsgi:app</code> inside of the virtual environment.</p>
  
  <p>Just in-case it is relevant, the nginx configuration:</p>
  
  <pre><code>server {
      listen 80;
      server_name myproject.com www.myproject.com;
  
      location / {
          include proxy_params;
          proxy_pass http://unix:/var/www/myproject/myproject.sock;
      }
  </code></pre>