Skip to content

Commit

Permalink
All varnish to set varnish file name
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldgray committed May 8, 2024
1 parent 6c2f649 commit a18b245
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ LABEL org.opencontainers.image.description="Varnish on Ubuntu, vcl sourced from
RUN apt-get update -y && apt-get install -y varnish python3-pip
RUN pip install awscli

COPY start.sh /start.sh
RUN chmod +x /start.sh

WORKDIR /usr/app/src
COPY varnish-cleanup/requirements.txt ./
RUN pip install -r requirements.txt

COPY start.sh /start.sh
RUN chmod +x /start.sh

COPY varnish-cleanup/cleanup_handler.py ./
COPY varnish-cleanup/app ./app

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ The following environment settings are expected:
* `VARNISH_CACHE_FOLDER` - Folder where disk backed cache is stored.
* `VARNISH_CACHE_SIZE` - Size of cache.
* `AWS_PROFILE` - Required to run locally
* `INCOMING_QUEUE` - the name of the queue that the cleanup handler listens to

The following configuration is optional:

* `VARNISH_CACHE_FILE` - The name of varnish [storage file](https://varnish-cache.org/docs/trunk/users-guide/storage-backends.html#file) (e.g. `varnish_cache.bin`). If specified it is appended to `VARNISH_CACHE_FOLDER` to create file (if unspecified folder only is used)
* `INCOMING_QUEUE` - the name of the queue that the cleanup handler listens to
* `VARNISH_ADDRESS` - The location of varnish used by the cleanup handler. Defaults to localhost
* `AWS_REGION` - The AWS region. Defaults to eu-west-1
* `USE_LOCAL_CONFIG` - Whether to use a local config file over S3.
Expand Down
15 changes: 10 additions & 5 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ RELOAD_VCL=1

mkdir -p ${VARNISH_CACHE_FOLDER}

varnishd -a 0.0.0.0:${VARNISH_PORT} -T 127.0.0.1:6082 -f /etc/varnish/default.vcl -s file,${VARNISH_CACHE_FOLDER}/varnish_cache.bin,${VARNISH_CACHE_SIZE}
varnishd -a 0.0.0.0:${VARNISH_PORT} -T 127.0.0.1:6082 -f /etc/varnish/default.vcl -s file,${VARNISH_CACHE_FOLDER}/${VARNISH_CACHE_FILE},${VARNISH_CACHE_SIZE}

varnishlog &

# Start varnish cleanup

python3 /usr/app/src/cleanup_handler.py
if [ -z "$INCOMING_QUEUE" ]
then
echo 'no queue monitoring'
varnishlog
else
# Start varnish cleanup
varnishlog &
python3 /usr/app/src/cleanup_handler.py
fi

0 comments on commit a18b245

Please sign in to comment.