[Flask] flask uwsgi nginx deployment not working

tigernassau tigernassau at gmail.com
Tue Oct 6 18:03:46 CEST 2015


we can only get Flask to load on a debian server with nginx, uwsgi with 
a command line statement, not on server boot - yet we can get bottle to 
load just fine.

most of the docs are either outdated, 80% complete, or different 
combinations (ie gunicorn, mod_wsgi, uwsgi-plugin-python, systemd ...) 
so we hope to write up a detailed set of docs that work for this combination

Here's what we have:
nginx.conf
      .....
       upstream testapp {
           server localhost: 8082;
       }
      .....
      location / {
               try_files $uri @wsgi;
       }
       location @wsgi {
               include /etc/nginx/uwsgi_params;
               uwsgi_pass testapp
       }
      .....

/etc/uwsgi/apps-enabled/testapp.ini
   [uwsgi]
   socket = localhost: 8082
   chdir = /home/testapp
   file = app.py
   master = true
   plugins = python
   uid = www-data
   gid = www-data
   vacuum = true

--- test command line run --- (works!)
sudo uwsgi --socket 127.0.0.1:8082 --wsgi-file /home/testapp/app.py 
--callable app processes 4 --stats 127.0.0.1:9191

/etc/systemd/system/testapp.service
[Unit]
Description=wsgi flask testapp
[Service]
ExecStart=uwsgi --socket 127.0.0.1:8082 --wsgi-file /home/testapp/app.py 
--callable app --processes 4
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all

[Install]
WantedBy=multi-user.target

sudo service testapp start ==> error

The only difference we see between Flask not booting and Bottle working 
is in the app run statement
Flask:
if __name__ == '__main__':
   app.run()

Bottle:
if __name__ == '__main__':
     bottle.run(host="127.0.0.1",port=8082)
else:
     app = application = bottle.default_app()


maybe app run issue ??
maybe permission issue ?? (but wsgi ini works for bottle)
maybe systemd service file ??

thks.

-- 
Tiger Nassau, Inc.
www.tigernassau.com



More information about the Flask mailing list