librelist archives

« back to archive

debug when deploy in uwsgi

debug when deploy in uwsgi

From:
linnchord
Date:
2011-10-19 @ 07:07
When I deploy the web app to test server(nginx+uwsgi) and set DEBUG=True, 
all 500 errors turn to be 502. Set DEBUG=False will be normal 500 error.  

The web log shows:

...upstream prematurely closed connection while reading response header 
from upstream…


why?  

-------------------------------
linnchord@gmail.com (mailto:linnchord@gmail.com)

Re: [flask] debug when deploy in uwsgi

From:
Roberto De Ioris
Date:
2011-10-19 @ 08:05
Il giorno 19/ott/2011, alle ore 09:07, linnchord ha scritto:

> When I deploy the web app to test server(nginx+uwsgi) and set 
DEBUG=True, all 500 errors turn to be 502. Set DEBUG=False will be normal 
500 error.
> 
> The web log shows:
> 
> ...upstream prematurely closed connection while reading response header 
from upstream…
> 
> 
> why?
> 
> 

You cannot use the flask/werkzeug debugger in forking environment:

http://flask.pocoo.org/docs/quickstart/#debug-mode

You see 502 because flask/werkzeug do not send any data to the webserver, 
so nginx will returns a 502.

You can emulate the debugger using --catch-exceptions option in uWSGI (but
please do not do it in production)

--
Roberto De Ioris
http://unbit.it
JID: roberto@jabber.unbit.it

回复: [flask] debug when deploy in uwsgi

From:
linnchord
Date:
2011-10-19 @ 09:02
Thanks! I got it.

-------------------------------
linnchord@gmail.com


在 2011年10月19日星期三,下午4:05,Roberto De Ioris 写道:

>  
> Il giorno 19/ott/2011, alle ore 09:07, linnchord ha scritto:
>  
> > When I deploy the web app to test server(nginx+uwsgi) and set 
DEBUG=True, all 500 errors turn to be 502. Set DEBUG=False will be normal 
500 error.
> >  
> > The web log shows:
> >  
> > ...upstream prematurely closed connection while reading response 
header from upstream…
> >  
> >  
> > why?
>  
> You cannot use the flask/werkzeug debugger in forking environment:
>  
> http://flask.pocoo.org/docs/quickstart/#debug-mode
>  
> You see 502 because flask/werkzeug do not send any data to the 
webserver, so nginx will returns a 502.
>  
> You can emulate the debugger using --catch-exceptions option in uWSGI 
(but please do not do it in production)
>  
> --
> Roberto De Ioris
> http://unbit.it
> JID: roberto@jabber.unbit.it (mailto:roberto@jabber.unbit.it)