"no python application found" uWSGI + nginx + Ubuntu 13

19,800

You should try to invest a bit of time in understanding all the components involved. For example you have merged the .ini uWSGI file with nginx.conf that is completely wrong. I can suggest you to start from here: http://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html

Try to understand every step (expecially the part about using official sources instead of distro packages). Start deploying without nginx (only uWSGI), and only after you are sure the thing is clear, you can proxy it behind nginx.

About gunicorn, yes it easier in the sense that it is written in python (so you do not need a c compiler to build it) and it has a minimal set of features, that reduce the amount of different configs you could find on the net (but really, avoid blind cut & paste, you should invest in understanding what is going on, otherwise your site will be down for ages at the first little problem). From what i can see/understand/immagine from your message, at the current state, using a WSGI server or another will not make difference for you.

Share:
19,800
RustyFluff
Author by

RustyFluff

Oh if only I had something witty to say.

Updated on June 17, 2022

Comments

  • RustyFluff
    RustyFluff almost 2 years

    I understand this is a common question but I've seen so many examples with frankenstein ini files that make no sense. Based on different systems with different file system layouts:

    e.g. /etc/uwsgi/vassals -vs- /etc/uwsgi/apps-{enabled|available} -vs- solo launching uwsgi

    So please for the love of my sanity after 14hrs of of brain damage:

    I have a basic Flask project with this layout:

    /srv/py/mylovelyapp/mylovelyapp.py
                       /models.py
                       /database.py
                       /static/
                       /templates/
    

    My monster of an ini file (located at /etc/uwsgi/apps-enabled/mylovelyapp.ini) is:

    [uwsgi]
    plugins = python
    base = /srv/py/mylovelyapp
    app = mylovelyapp
    callable = app
    gid = www-data
    uid = www-data
    vhost = true
    socket = 127.0.0.1:3031
    master = true
    processes = 1
    harakiri = 20
    limit-as = 128
    

    nginx config at /etc/nginx/sites-enabled/mysite.conf:

    server {
    listen 80;
    server_name www.mylovelyapp.co.uk mylovelyapp.co.uk;
    
    charset     utf-8;
    client_max_body_size 75M;
    
    location / { try_files $uri @yourapplication; }
    location @yourapplication {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:3031;
    }
    location /static/ {
        alias /srv/py/mylovelyapp/static/;
        expires 30d;
        access_log off;
    }
    
    access_log /var/log/nginx/mylovelyapp-a.conf;
    error_log /var/log/nginx/mylovelyapp-e.conf;
    }
    

    The error output I get when tailing the /var/log/uwsgi/mylovelyapp.log is this:

    Mon May 26 06:41:40 2014 - *** Python threads support is disabled. You can enable it with --enable-threads ***
    Mon May 26 06:41:40 2014 - Python main interpreter initialized at 0x1445e50
    Mon May 26 06:41:40 2014 - your server socket listen backlog is limited to 100 connections
    Mon May 26 06:41:40 2014 - your mercy for graceful operations on workers is 60 seconds
    Mon May 26 06:41:40 2014 - mapped 145536 bytes (142 KB) for 1 cores
    Mon May 26 06:41:40 2014 - *** Operational MODE: single process ***
    Mon May 26 06:41:40 2014 - *** no app loaded. going in full dynamic mode ***
    Mon May 26 06:41:40 2014 - *** uWSGI is running in multiple interpreter mode ***
    Mon May 26 06:41:40 2014 - spawned uWSGI master process (pid: 2380)
    Mon May 26 06:41:40 2014 - spawned uWSGI worker 1 (pid: 2388, cores: 1)
    

    While visiting the URL gives the message:

    Internal Server Error
    

    I know I'm missing some easy reference but I'm trying allsorts of trual and error as well as Googling but comeing across examples that are all alightly unfitting for my use. An yet infuriatingly its such a simple app and setup!!

    Please, please help. :(

    P.S.. Bonus love and eternal gratitude if you can tell me how to make it use the virtual machine for that flask app.

    P.P.S I've heard Gunicorn is easier - maybe I should switch to that?

  • RustyFluff
    RustyFluff almost 10 years
    That was a formatting error in my post. The nginx file is in separate location. I've had this working before so I know I can set it up. Its just my server recently died and I'm having to re-remember how to get uWSGI running my Flask apps again.
  • roberto
    roberto almost 10 years
    ok, the advice does not change, follow the uWSGI quickstart, i find hard to believe that your first deployment attempt requires such a big .ini file with virtualhosting enabled (something really uncommon) and address space limiting. You get that error because your app has not been loaded by uWSGI.
  • RustyFluff
    RustyFluff almost 10 years
    I followed your advice and tried the example command "uwsgi --socket 127.0.0.1:3031 --wsgi-file myappfile.py --callable app --processes 4 --threads 2" but get the error: "uwsgi: unrecognized option '--wsgi-file'" So the RTFM advice you gave doesn't work!
  • roberto
    roberto almost 10 years
    follow the quickstart from the start to the end, it warns you multiple times about not using distro packages when learning. (infact the error you get is because you are using a distro package that requires explicit loading of the python plugin). "pip install uwsgi" is cheap and fast
  • RustyFluff
    RustyFluff almost 10 years
    You're absolutely right. I was being impatient. Not only have I got it working but I now understand uwsgi and the process of managing it much better now. Thank you for being patient in the face of my stubborn ignorance. :)