Skip to content

Commit

Permalink
feat: enable logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ludovicm67 committed May 21, 2024
1 parent 413f7b3 commit d247546
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/sour-humans-run.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
11 changes: 9 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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}" \
Expand Down

0 comments on commit d247546

Please sign in to comment.