jeudi 17 janvier 2019

Debugging python flask on production with uswgi on remote server

I have a site live in production, with one endpoint API that I created while ago for a test, it simply is a URL accepting a parameter.

When I call it, it return error 500.

Now, If I run flask locally, I can see the trace on the web console, and can find what was wrong.

But I would like to see if possible to obtain the same stack trace on the remote server, for a "quick" fix.

I helped myself by launching a temporary app from a new port and display on standard input:

uwsgi --http :9090 --callable application --wsgi-file myApp.py --honour-stdin

as suggested in: How to debug python application under uWSGI?

but I see no effect when I curl my endpoint, :

*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 6936, cores: 1)
[pid: 6936|app: 0|req: 1/1] 127.0.0.1 () {28 vars in 359 bytes} [Thu Jan 17 10:49:46 2019] GET /api/node/wPAyD8rYPmR47VkE/?field=uid => generated 3436 bytes in 18 msecs (HTTP/1.1 500) 2 headers in 100 bytes (1 switches on core 0)

I see that uwsgi simply reports the error 500, while I wanna see the python trace where the app failed.

As an example, in my local env, it turned out I got a ValueError:

I would like to see that error reported somewhere by uwsgi, showing the race ad the line where the app failed.

How could I display python failures in my app, using uwsgi - avoiding to run local env, that usefully display the trace on the console ?

Aucun commentaire:

Enregistrer un commentaire