mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
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:
parent
f05f1dbac7
commit
3005e82f60
2 changed files with 7 additions and 7 deletions
|
@ -13,7 +13,6 @@ from fastapi import FastAPI, HTTPException, Request, Response
|
||||||
from fastapi.responses import RedirectResponse
|
from fastapi.responses import RedirectResponse
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
from jinja2 import TemplateNotFound
|
from jinja2 import TemplateNotFound
|
||||||
from prometheus_client import multiprocess
|
|
||||||
from sqlalchemy import and_
|
from sqlalchemy import and_
|
||||||
from starlette.exceptions import HTTPException as StarletteHTTPException
|
from starlette.exceptions import HTTPException as StarletteHTTPException
|
||||||
from starlette.middleware.authentication import AuthenticationMiddleware
|
from starlette.middleware.authentication import AuthenticationMiddleware
|
||||||
|
@ -91,12 +90,6 @@ async def app_startup():
|
||||||
get_engine()
|
get_engine()
|
||||||
|
|
||||||
|
|
||||||
def child_exit(server, worker): # pragma: no cover
|
|
||||||
"""This function is required for gunicorn customization
|
|
||||||
of prometheus multiprocessing."""
|
|
||||||
multiprocess.mark_process_dead(worker.pid)
|
|
||||||
|
|
||||||
|
|
||||||
async def internal_server_error(request: Request, exc: Exception) -> Response:
|
async def internal_server_error(request: Request, exc: Exception) -> Response:
|
||||||
"""
|
"""
|
||||||
Catch all uncaught Exceptions thrown in a route.
|
Catch all uncaught Exceptions thrown in a route.
|
||||||
|
|
7
gunicorn.conf.py
Normal file
7
gunicorn.conf.py
Normal 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)
|
Loading…
Add table
Reference in a new issue