[Flask] flask uwsgi nginx deployment not working
Jeff Widman
jeff at jeffwidman.com
Thu Oct 15 22:35:17 CEST 2015
Sure, here's a blog post showing my working config for Flask + uWSGI
Emperor + Nginx:
http://www.jeffwidman.com/blog/802/serving-multiple-flask-apps-via-uwsgi-nginx/
Feel free to ask questions or suggest improvements...
ᐧ
On Tue, Oct 6, 2015 at 4:03 PM, tigernassau <tigernassau at gmail.com> wrote:
> Hmm, looked at pull request - more confusion! Would try emperor but see
> no docs on that - is your setup something you can post?. Otherwise we have
> Bottle working nicely (and only seems to be missing session vs Flask, so it
> might be easier to just get Beaker working with Bottle
>
> On 10/06/2015 03:03 PM, Jeff Widman wrote:
>
> I just setup Nginx + uWSGI + Flask the other day for the first time.
> You're right, the Flask docs on uWSGI are outdated and use deprecated uWSGI
> commands. There's a pull request in the Flask repo that shows the correct
> way (as best I could tell) to set things up, it also covers the slightly
> more complicated scenario of serving multiple Flask apps on a single uWSGI
> socket.
>
> I take a cursory look through your code and nothing stuck out to me... I
> used the Emperor option in place of the Master process option, as it gives
> more flexibility, so maybe that's why I'm not seeing the specific issue...
> maybe try that?
> ᐧ
>
> On Tue, Oct 6, 2015 at 9:03 AM, tigernassau <tigernassau at gmail.com> wrote:
>
>> 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
>>
>> _______________________________________________
>> Flask mailing list
>> Flask at python.org
>> https://mail.python.org/mailman/listinfo/flask
>>
>
>
>
> --
>
> * Jeff Widman*
> jeffwidman.com <http://www.jeffwidman.com/> | 740-WIDMAN-J (943-6265)
> <><
>
>
> _______________________________________________
> Flask mailing listFlask at python.orghttps://mail.python.org/mailman/listinfo/flask
>
>
>
> --
> Tiger Nassau, Inc.www.tigernassau.com
>
>
--
*Jeff Widman*
jeffwidman.com <http://www.jeffwidman.com/> | 740-WIDMAN-J (943-6265)
<><
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20151015/cae811d0/attachment.html>
More information about the Flask
mailing list