From d247546ba459404bd419305266c772a4e441891c Mon Sep 17 00:00:00 2001 From: Ludovic Muller Date: Tue, 21 May 2024 15:15:51 +0200 Subject: [PATCH] feat: enable logs --- .changeset/sour-humans-run.md | 6 ++++++ Dockerfile | 1 + README.md | 1 + entrypoint.sh | 11 +++++++++-- 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .changeset/sour-humans-run.md diff --git a/.changeset/sour-humans-run.md b/.changeset/sour-humans-run.md new file mode 100644 index 0000000..53c6e3a --- /dev/null +++ b/.changeset/sour-humans-run.md @@ -0,0 +1,6 @@ +--- +"varnish-post": minor +--- + +It is now possible to enable logs, by setting `ENABLE_LOGS` to `true`, which is now the default value. +To disable them, just put any other value, like `false` for example. diff --git a/Dockerfile b/Dockerfile index c0850f8..a42b373 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,7 @@ ENV VARNISH_SIZE="100M" ENV DISABLE_ERROR_CACHING="true" ENV DISABLE_ERROR_CACHING_TTL="30s" ENV CONFIG_FILE="default.vcl" +ENV ENABLE_LOGS="true" # Install some dependencies RUN apt-get update \ diff --git a/README.md b/README.md index 4be705b..9eb6e7e 100644 --- a/README.md +++ b/README.md @@ -26,3 +26,4 @@ You can use following environment variables for configuration: - `DISABLE_ERROR_CACHING`: disable the caching of errors (default: `true`) - `DISABLE_ERROR_CACHING_TTL`: time where requests should be directly sent to the backend after an error occured (default: `30s`) - `CONFIG_FILE`: the name of the configuration file to use (default: `default.vcl`) +- `ENABLE_LOGS`: enable logs (default: `true`) diff --git a/entrypoint.sh b/entrypoint.sh index 998b62c..b46ad1d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,8 +1,10 @@ #!/bin/sh +ENABLE_LOGS="${ENABLE_LOGS}" + set -eu -# environment variables substitution +# Environment variables substitution for SRC_LOCATION in $(find /templates -type f); do DST_LOCATION=$(echo "${SRC_LOCATION}" | sed 's/^\/templates/\/etc\/varnish/') envsubst \ @@ -11,9 +13,14 @@ for SRC_LOCATION in $(find /templates -type f); do echo "INFO: generated '${DST_LOCATION}' from '${SRC_LOCATION}' (environment variables substitution)" done +# Display logs if configured +if [ "${ENABLE_LOGS}" = "true" ]; then + varnishncsa& +fi + set -x -# run varnish +# Run Varnish varnishd \ -F \ -f "/etc/varnish/${CONFIG_FILE}" \