librelist archives

« back to archive

What is the best way to debug a flask app in deployment?

What is the best way to debug a flask app in deployment?

From:
Adam Hogan
Date:
2013-04-27 @ 22:31
Hey kind people,

I have a flask app that works perfectly locally.  I have nginx and uwsgi 
set up on a remote server, and my home page works fine. However, when I 
perform any actions to update my database, I get a 502 error.  I can't 
figure out how to debug this, or what's causing it.  Locally, I'm happy 
to just see the log, but remotely, I face two problems:

1. I try to use the python server with debug=True,local-only debugging 
environment, on port 5000, and there's no http server for me to actually 
test it in my browser---so I still don't know what the error is.
2. I read the nginx and uwsgi logs, but they don't tell me what the 
database error is.

I am not sure why I can run locally but not on my development server, 
but I could certainly use the ability to access a python error log to 
tell me something like "function failing on line X of file Y."

What are the best ways of seeing this kind of output?  Or if impossible, 
how do you debug your dev?

Thanks!
Adam

Re: [flask] What is the best way to debug a flask app in deployment?

From:
Spacelee
Date:
2013-04-28 @ 07:08
I use Gunicorn+Gevent+Flask,  when I enable the gunicorn 's DEBUG, it will
catch Flask's error log to gunicorn's log, and it's the same with what you
see when you start your flask directly...You could refer to the source
code: https://github.com/fjctlzy/myflask


On Sun, Apr 28, 2013 at 6:31 AM, Adam Hogan <hoganaj.junk@gmail.com> wrote:

> Hey kind people,
>
> I have a flask app that works perfectly locally.  I have nginx and uwsgi
> set up on a remote server, and my home page works fine. However, when I
> perform any actions to update my database, I get a 502 error.  I can't
> figure out how to debug this, or what's causing it.  Locally, I'm happy
> to just see the log, but remotely, I face two problems:
>
> 1. I try to use the python server with debug=True,local-only debugging
> environment, on port 5000, and there's no http server for me to actually
> test it in my browser---so I still don't know what the error is.
> 2. I read the nginx and uwsgi logs, but they don't tell me what the
> database error is.
>
> I am not sure why I can run locally but not on my development server,
> but I could certainly use the ability to access a python error log to
> tell me something like "function failing on line X of file Y."
>
> What are the best ways of seeing this kind of output?  Or if impossible,
> how do you debug your dev?
>
> Thanks!
> Adam
>



-- 
*Space Lee*

Re: [flask] What is the best way to debug a flask app in deployment?

From:
Serge S. Koval
Date:
2013-04-28 @ 07:21
Do you run your flask application under supervisor?

If yes, enable logs in your application config and check stderr log.

I guess there's permission issue related to your database. For example, if
you use sqlite, make sure you use full path to the database. If you use
other database, make sure that credentials and/or user context is correct.

Serge.


On Sun, Apr 28, 2013 at 10:08 AM, Spacelee <fjctlzy@gmail.com> wrote:

> I use Gunicorn+Gevent+Flask,  when I enable the gunicorn 's DEBUG, it will
> catch Flask's error log to gunicorn's log, and it's the same with what you
> see when you start your flask directly...You could refer to the source
> code: https://github.com/fjctlzy/myflask
>
>
> On Sun, Apr 28, 2013 at 6:31 AM, Adam Hogan <hoganaj.junk@gmail.com>wrote:
>
>> Hey kind people,
>>
>> I have a flask app that works perfectly locally.  I have nginx and uwsgi
>> set up on a remote server, and my home page works fine. However, when I
>> perform any actions to update my database, I get a 502 error.  I can't
>> figure out how to debug this, or what's causing it.  Locally, I'm happy
>> to just see the log, but remotely, I face two problems:
>>
>> 1. I try to use the python server with debug=True,local-only debugging
>> environment, on port 5000, and there's no http server for me to actually
>> test it in my browser---so I still don't know what the error is.
>> 2. I read the nginx and uwsgi logs, but they don't tell me what the
>> database error is.
>>
>> I am not sure why I can run locally but not on my development server,
>> but I could certainly use the ability to access a python error log to
>> tell me something like "function failing on line X of file Y."
>>
>> What are the best ways of seeing this kind of output?  Or if impossible,
>> how do you debug your dev?
>>
>> Thanks!
>> Adam
>>
>
>
>
> --
> *Space Lee*
>

Re: [flask] What is the best way to debug a flask app in deployment?

From:
Igor Davydenko
Date:
2013-04-28 @ 10:19
Enable logging is good starting point, but you also can try Wdb or other
debug WSGI middlewares if you want some more options while debugging

Wdb: https://github.com/Kozea/wdb
On Apr 28, 2013 1:32 AM, "Adam Hogan" <hoganaj.junk@gmail.com> wrote:

> Hey kind people,
>
> I have a flask app that works perfectly locally.  I have nginx and uwsgi
> set up on a remote server, and my home page works fine. However, when I
> perform any actions to update my database, I get a 502 error.  I can't
> figure out how to debug this, or what's causing it.  Locally, I'm happy
> to just see the log, but remotely, I face two problems:
>
> 1. I try to use the python server with debug=True,local-only debugging
> environment, on port 5000, and there's no http server for me to actually
> test it in my browser---so I still don't know what the error is.
> 2. I read the nginx and uwsgi logs, but they don't tell me what the
> database error is.
>
> I am not sure why I can run locally but not on my development server,
> but I could certainly use the ability to access a python error log to
> tell me something like "function failing on line X of file Y."
>
> What are the best ways of seeing this kind of output?  Or if impossible,
> how do you debug your dev?
>
> Thanks!
> Adam
>

Re: [flask] What is the best way to debug a flask app in deployment?

From:
宣铭艺
Date:
2013-04-27 @ 22:42
于 13-4-28 上午6:31, Adam Hogan 写道:
> Hey kind people,
>
> I have a flask app that works perfectly locally.  I have nginx and uwsgi
> set up on a remote server, and my home page works fine. However, when I
> perform any actions to update my database, I get a 502 error.  I can't
> figure out how to debug this, or what's causing it.  Locally, I'm happy
> to just see the log, but remotely, I face two problems:
>
> 1. I try to use the python server with debug=True,local-only debugging
> environment, on port 5000, and there's no http server for me to actually
> test it in my browser---so I still don't know what the error is.
> 2. I read the nginx and uwsgi logs, but they don't tell me what the
> database error is.
>
> I am not sure why I can run locally but not on my development server,
> but I could certainly use the ability to access a python error log to
> tell me something like "function failing on line X of file Y."
>
> What are the best ways of seeing this kind of output?  Or if impossible,
> how do you debug your dev?
>
> Thanks!
> Adam
> y
I think you may need pdb
like this:
import pdb;pdb.set_trace()