From c3b49cca250b00881c44c50c65fd372d4d8d2180 Mon Sep 17 00:00:00 2001 From: Paulo Coutinho Date: Thu, 10 Oct 2024 23:09:17 -0300 Subject: [PATCH] Only trigger prometheus if configured (#231) * fix prometheus integration * fix prometheus integration * Add also lowercase option As they seem to support that too: https://github.com/prometheus/client_python/blob/d7c9cd88c7f50097cd86869974301df7615bc9c0/prometheus_client/multiprocess.py#L166-L167 * format --------- Co-authored-by: Stan Triepels <1939656+GDay@users.noreply.github.com> --- django_q/cluster.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/django_q/cluster.py b/django_q/cluster.py index 79ce10a..23c9049 100644 --- a/django_q/cluster.py +++ b/django_q/cluster.py @@ -1,4 +1,5 @@ # Standard +import os import signal import socket import uuid @@ -230,8 +231,14 @@ class Sentinel: % {"name": process.name} ) else: - if prometheus_multiprocess: + # check if prometheus is proper configurated + prometheus_path = os.getenv( + "PROMETHEUS_MULTIPROC_DIR", os.getenv("prometheus_multiproc_dir") + ) + + if prometheus_multiprocess and prometheus_path: prometheus_multiprocess.mark_process_dead(process.pid) + self.pool.remove(process) self.spawn_worker() if process.timer.value == 0: