简体   繁体   中英

uwsgi - can't see traceback in log file

I'm using uwsgi to run a small service written in flask.

I launch it like this:

flask/bin/uwsgi --http :9090 --master --pidfile /tmp/KVAutobus-uwsgi.pid  --processes 30 --threads 2 --wsgi-file app.py --callable app --stats :9191 --daemonize /opt/logs/KVAutobus-uwsgi.log

It seems to work, but I just hit a 500 error during a request and I want to see the traceback that the flask app produced but I can't find it. Do I need different logging options?

Here's all that's in the log file after the 500 error:

>tail /opt/logs/KVAutobus-uwsgi.log

*** Stats server enabled on :9191 fd: 135 ***
spawned uWSGI http 1 (pid: 20124)
[pid: 20060|app: 0|req: 1/1] 10.36.100.18 () {34 vars in 709 bytes} [Tue Jun 30 14:29:57 2015] DELETE /kvautobus/api/clear_cache_range/MDAwMDAwMDA1NTA0MDAwMDAwMDQwOTYwMDAwMDAwMTczMDU2/MDAwMDAwMDA1NTA0MDAwMDAwMDQwOTYwMDAwMDAwMTg0NDQ4/ => generated 291 bytes in 30023 msecs (HTTP/1.1 500) 2 headers in 84 bytes (1 switches on core 0)

Ok, @ipinak was on the right track. It looks like Flask is gobbling up the error and not propagating it.

Here's the answer I found that fixes it. If the link breaks, it's basically setting this in your app:

from flask import Flask
application = Flask(__name__)
application.config['PROPAGATE_EXCEPTIONS'] = True

I don't think you can do that there, you need to add logging inside your application, (that's what I do). Here are information about data you can log https://uwsgi-docs.readthedocs.org/en/latest/LogFormat.html?highlight=log . Also, I would suggest you to remove --daemonize option and instead use supervisord , to have process control.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM