diff --git a/backend/Dockerfile b/backend/Dockerfile index 0f1f475..b363917 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -16,4 +16,5 @@ ENV OSM_CACHE_DIR=/cache ENV MEMCACHED_HOST_PATH=none ENV LOKI_URL=none -CMD ["fastapi", "src/main.py", "--port", "8000", "--workers", "$NUM_WORKERS"] +# explicitly use a string instead of an argument list to force a shell and variable expansion +CMD fastapi run src/main.py --port 8000 --workers $NUM_WORKERS diff --git a/backend/src/logging_config.py b/backend/src/logging_config.py index 0f93fa7..c43a246 100644 --- a/backend/src/logging_config.py +++ b/backend/src/logging_config.py @@ -15,7 +15,7 @@ def configure_logging(): is_kubernetes = os.getenv('KUBERNETES_SERVICE_HOST') is not None - if not is_kubernetes: + if is_kubernetes: # in that case we want to log to stdout and also to loki from loki_logger_handler.loki_logger_handler import LokiLoggerHandler loki_url = os.getenv('LOKI_URL') @@ -31,6 +31,8 @@ def configure_logging(): logger.info(f"Logging to Loki at {loki_url} with {loki_handler.labels} and {is_debug=}") logging_handlers = [loki_handler, logging.StreamHandler()] logging_level = logging.DEBUG if is_debug else logging.INFO + # silence the chatty logs loki generates itself + logging.getLogger('urllib3.connectionpool').setLevel(logging.WARNING) # no need for time since it's added by loki or can be shown in kube logs logging_format = '%(name)s - %(levelname)s - %(message)s'