[Flask] Finding error in Flask app while running under web server

Anthony Ford ford.anthonyj at gmail.com
Tue May 10 12:50:56 EDT 2016


Good catch (no pun intended).

Permissions with log files/dirs can be a big (and annoying) problem. You
may have already found it, but there's a way to have uWSGI change log
permissions (assuming you are starting uWSGI with high enough privs, such
as using the uWSGI emperor or your systemd/sysinit). I use it in the gist I
sent earlier (
https://gist.github.com/ajford/32ca09c1bdb67e2211247f189aa2ae9a#file-foobar-wsgi-L20),
"log-chmod", and it's fellow, "log-chown". Only works if you do start with
high/root privs and downgrade with the "uid" and "gid" flags.

Oh software, the realm of debugging and logging.

Anthony Ford,
KF5IBN,
ford.anthonyj at gmail.com

On Tue, May 10, 2016 at 11:41 AM, Alex Hall <ahall at autodist.com> wrote:

> Thanks, good to know I'm not missing another automatic log file somewhere.
>
> I also discovered that you can set catch-exceptions in UWSGI to true, and
> that will cause any problems to be printed. That may not help Flask
> directly, but it explains why my UWSGI log was always empty, as it showed a
> permissions problem with the file. If I printed with Flask, I wouldn't have
> seen anything, and I would never have known why were it not for
> catch-exceptions.
>
>
> On Tue, May 10, 2016 at 12:35 PM, Anthony Ford <ford.anthonyj at gmail.com>
> wrote:
>
>> Yeah, your best bet is probably to try some logging in Python.
>>
>> If I'm not mistaken, you can cheat by just "print"ing to STDOUT, and
>> uwsgi should record that in its log, but in the long run, setting up proper
>> logging is probably best (even with how much of a PITA the python logging
>> module is).
>>
>>
>>
>> Anthony Ford,
>> KF5IBN,
>> ford.anthonyj at gmail.com
>>
>> On Tue, May 10, 2016 at 11:07 AM, Alex Hall <ahall at autodist.com> wrote:
>>
>>> Hello list,
>>> I'm delighted to say that, not five minutes ago, my app ran under Nginx!
>>> I'm still not totally sure how it's doing it, but it is. Now, though, I'm
>>> running into a problem: something is timing out. I can see that in the
>>> Nginx log, and my page displays a generic error message, one it shows if
>>> anything goes sideways while talking to the database or interpreting
>>> results.
>>>
>>> I'm pretty sure the issue is in my app's communication with our AS400,
>>> but I don't know how to double check that. The UWSGI log for this app is
>>> empty, which doesn't surprise me as this is likely a problem with my app's
>>> code. Is Python logging the best way to go here, or is there some automated
>>> log I'm overlooking?
>>>
>>> Thanks for any answers, and thanks again for everyone's help. I'm
>>> thrilled that this finally--almost--works. It renders properly, which is
>>> the main thing. Hopefully, it'll all be downhill from here. :)
>>>
>>> --
>>> Alex Hall
>>> Automatic Distributors, IT department
>>> ahall at autodist.com
>>>
>>> _______________________________________________
>>> Flask mailing list
>>> Flask at python.org
>>> https://mail.python.org/mailman/listinfo/flask
>>>
>>>
>>
>
>
> --
> Alex Hall
> Automatic Distributors, IT department
> ahall at autodist.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160510/6d6356b9/attachment-0001.html>


More information about the Flask mailing list