Ray P.
Ray P.

Reputation: 925

Logging uWSGI application stop in Python

I have a Flask app that I run with uWSGI. I have configured logging to file in the Python/Flask application, so on service start it logs that the application has been started.

I want to be able to do this when the service stops as well, but I don't know how to implement it.

For example, if I run the uwsgi app in console, and then interrupt it with Ctrl-C, I get only uwsgi logs ("Goodbye to uwsgi" etc) in console, but no logs from the stopped python application. Not sure how to do this.

I would be glad if someone advised on possible solutions.

Edit: I've tried to use Python's atexit module, but the function that I registered to run on exit is executed not one time, but 4 times (which is the number of uWSGI workers).

Upvotes: 0

Views: 231

Answers (1)

davidism
davidism

Reputation: 127190

There is no "stop" event in WSGI, so there is no way to detect when the application stops, only when the server / worker stops.

Upvotes: 1

Related Questions