From ac45148276b1f2e45977cb46759005d7448cc5ea Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org>
Date: Wed, 14 Aug 2024 14:03:37 +0200
Subject: [PATCH] web: Allow gunicorn logging config to be effective

Refs. swh/infra/sysadm-environment#5327
---
 apps/swh-web/entrypoint.sh    | 5 +++++
 apps/swh-web/requirements.txt | 1 +
 2 files changed, 6 insertions(+)

diff --git a/apps/swh-web/entrypoint.sh b/apps/swh-web/entrypoint.sh
index 98a0816a7..af132aa18 100755
--- a/apps/swh-web/entrypoint.sh
+++ b/apps/swh-web/entrypoint.sh
@@ -23,10 +23,15 @@ case "$1" in
         exec sh -c "django-admin sync_mailmaps --perform '$@'"
         ;;
     *)
+        EXTRA_CLI_FLAGS=""
+        if [ ! -z "${SWH_LOG_CONFIG_JSON}" ]; then
+            EXTRA_CLI_FLAGS="--log-config-json ${SWH_LOG_CONFIG_JSON}"
+        fi
         echo "Starting the swh-web server"
         # run gunicorn workers as in production otherwise
         exec gunicorn --bind 0.0.0.0:${PORT} \
              --log-level ${SWH_LOG_LEVEL:-INFO} \
+             ${EXTRA_CLI_FLAGS} \
              --threads ${THREADS} \
              --workers ${WORKERS} \
              --timeout ${TIMEOUT} \
diff --git a/apps/swh-web/requirements.txt b/apps/swh-web/requirements.txt
index 373fe5543..c4c66dbed 100644
--- a/apps/swh-web/requirements.txt
+++ b/apps/swh-web/requirements.txt
@@ -1 +1,2 @@
 swh.web
+python-json-logger
-- 
GitLab