fix: Cleanup prometheus metrics for dead workers

The current "cleanup" function that is removing orphan prometheus files
is actually never invoked.
We move this to a default gunicorn config file to register our hook(s).

https://docs.gunicorn.org/en/stable/configure.html
https://docs.gunicorn.org/en/stable/settings.html#child-exit
Signed-off-by: moson <moson@archlinux.org>
This commit is contained in:
moson 2023-08-18 22:04:55 +02:00
parent f05f1dbac7
commit 3005e82f60
No known key found for this signature in database
GPG key ID: 4A4760AB4EE15296
2 changed files with 7 additions and 7 deletions

7
gunicorn.conf.py Normal file
View file

@ -0,0 +1,7 @@
from prometheus_client import multiprocess
def child_exit(server, worker): # pragma: no cover
"""This function is required for gunicorn customization
of prometheus multiprocessing."""
multiprocess.mark_process_dead(worker.pid)