Revert "lifecycle: use worker nr instead of process id to keep number of prometheus database files low"
This reverts commit 254249e38b
.
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
84930b4924
commit
15d8988569
|
@ -7,14 +7,11 @@ from tempfile import gettempdir
|
||||||
|
|
||||||
import structlog
|
import structlog
|
||||||
from kubernetes.config.incluster_config import SERVICE_HOST_ENV_NAME
|
from kubernetes.config.incluster_config import SERVICE_HOST_ENV_NAME
|
||||||
from prometheus_client import values
|
|
||||||
from prometheus_client.values import MultiProcessValue
|
|
||||||
|
|
||||||
from authentik import get_full_version
|
from authentik import get_full_version
|
||||||
from authentik.lib.config import CONFIG
|
from authentik.lib.config import CONFIG
|
||||||
from authentik.lib.utils.http import get_http_session
|
from authentik.lib.utils.http import get_http_session
|
||||||
from authentik.lib.utils.reflection import get_env
|
from authentik.lib.utils.reflection import get_env
|
||||||
from lifecycle.worker import DjangoUvicornWorker
|
|
||||||
|
|
||||||
bind = "127.0.0.1:8000"
|
bind = "127.0.0.1:8000"
|
||||||
|
|
||||||
|
@ -72,17 +69,11 @@ workers = int(os.environ.get("WORKERS", default_workers))
|
||||||
threads = int(os.environ.get("THREADS", 4))
|
threads = int(os.environ.get("THREADS", 4))
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def post_fork(server, worker: DjangoUvicornWorker):
|
def worker_exit(server, worker):
|
||||||
"""Tell prometheus to use worker number instead of process ID for multiprocess"""
|
|
||||||
values.ValueClass = MultiProcessValue(lambda: worker.nr)
|
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
|
||||||
def worker_exit(server, worker: DjangoUvicornWorker):
|
|
||||||
"""Remove pid dbs when worker is shutdown"""
|
"""Remove pid dbs when worker is shutdown"""
|
||||||
from prometheus_client import multiprocess
|
from prometheus_client import multiprocess
|
||||||
|
|
||||||
multiprocess.mark_process_dead(worker.nr)
|
multiprocess.mark_process_dead(worker.pid)
|
||||||
|
|
||||||
|
|
||||||
if not CONFIG.y_bool("disable_startup_analytics", False):
|
if not CONFIG.y_bool("disable_startup_analytics", False):
|
||||||
|
|
Reference in New Issue