Frage

My goal is rotating the logs generated by uWSGI, but when the original log file is deleted (after compression) it is not re-created again.

So I thought that the app needs a graceful restart of the master process after the file is deleted. I use this RESTART script:

/home/tester/uwsgi-18
--reload /var/run/uwsgi/my_app_tester/my_app_tester.pid

The app restart, but the log does not.

To get the logging work again I need to kill -2 the process and run the START script again, so another process number is generated and the logging works again.

Obviously I do not want such hard STOP just for rotating logs...

My app is built with Catalyst, the server runs Nginx and here it is the uWSGI START script:

/home/tester/uwsgi-18
--master
--daemonize /var/log/uwsgi/my_app_tester/log
--socket /tmp/uwsgi/my_app_tester/my_app_tester.socket
--processes 1
--psgi /home/tester/my_app/my_app.psgi
--pidfile /var/run/uwsgi/my_app_tester/my_app_tester.pid
--procname-master TESTER
-L

Is there another way to restart the app without loosing connections and logging?

Thank you in advance: Migue

War es hilfreich?

Lösung

You have various approaches:

1) copytruncate in the logrotate script, this will work reliably and without the help of uWSGI

2) uWSGI log rotation: --log-maxsize <bytes> will automatically rotate logs when a specific size is reached

3) classic logrotation + log reloading, just add --log-master and trigger log reloading with http://uwsgi-docs.readthedocs.org/en/latest/MasterFIFO.html

There are other approaches too (like triggering the log reopen when touching a files), but the previous one are the most common.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top