diff --git a/Dockerfile b/Dockerfile index 2fca67d..1d3008c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/README.md b/README.md index 7dfcae4..e143aa0 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/start.sh b/start.sh index 391e6f2..d3221b1 100755 --- a/start.sh +++ b/start.sh @@ -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 \ No newline at end of file