From 19f55df40fbd170a2c543be6c29bb5ffde4f2f83 Mon Sep 17 00:00:00 2001 From: Marlon Saglia Date: Mon, 30 Apr 2018 10:19:39 +0200 Subject: [PATCH 1/5] Allow setting an alternative, custom, backend storage while preserving backward compatiblity with VARNISHD_STORAGE_SIZE --- 4/templates/varnishd.init.d.tpl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) mode change 100644 => 100755 4/templates/varnishd.init.d.tpl diff --git a/4/templates/varnishd.init.d.tpl b/4/templates/varnishd.init.d.tpl old mode 100644 new mode 100755 index ca298c1..500ec5b --- a/4/templates/varnishd.init.d.tpl +++ b/4/templates/varnishd.init.d.tpl @@ -6,6 +6,14 @@ if [[ -n "${DEBUG}" ]]; then set -x fi +{{ $alternative_storage := false }} +{{ if getenv "VARNISHD_STORAGE_SIZE" }} + {{ $alternative_storage := (printf "file,/var/lib/varnish/storage.bin,%s" (getenv "VARNISHD_STORAGE_SIZE")) }} +{{ else if getenv "VARNISHD_STORAGE_CUSTOM" }} + {{ $alternative_storage := (getenv "VARNISHD_STORAGE_CUSTOM") }} +{{ end }} + + exec varnishd \ -j unix,user=varnish \ -F \ @@ -14,7 +22,7 @@ exec varnishd \ -f {{ getenv "VARNISHD_VCL_SCRIPT" "/etc/varnish/default.vcl" }} \ -S {{ getenv "VARNISHD_SECRET_FILE" "/etc/varnish/secret" }} \ -s main=malloc,{{ getenv "VARNISHD_MEMORY_SIZE" "64M" }} \ - {{ if getenv "VARNISHD_STORAGE_SIZE" }}-s secondary=file,/var/lib/varnish/storage.bin,{{ getenv "VARNISHD_STORAGE_SIZE" }} {{ end }} \ + {{ if $alternative_storage }} -s secondary={{ $alternative_storage }} {{ end }}\ -t {{ getenv "VARNISHD_DEFAULT_TTL" "120" }} \ -p ban_lurker_age={{ getenv "VARNISHD_PARAM_BAN_LURKER_AGE" "60.000" }} \ -p ban_lurker_batch={{ getenv "VARNISHD_PARAM_BAN_LURKER_BATCH" "1000" }} \ From 559714adbc9b897b4c1892659480af63f92fd0d8 Mon Sep 17 00:00:00 2001 From: Marlon Saglia Date: Wed, 2 May 2018 08:51:10 +0200 Subject: [PATCH 2/5] Improve secondary storage variable name --- 4/templates/varnishd.init.d.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/4/templates/varnishd.init.d.tpl b/4/templates/varnishd.init.d.tpl index 500ec5b..22c2545 100755 --- a/4/templates/varnishd.init.d.tpl +++ b/4/templates/varnishd.init.d.tpl @@ -9,8 +9,8 @@ fi {{ $alternative_storage := false }} {{ if getenv "VARNISHD_STORAGE_SIZE" }} {{ $alternative_storage := (printf "file,/var/lib/varnish/storage.bin,%s" (getenv "VARNISHD_STORAGE_SIZE")) }} -{{ else if getenv "VARNISHD_STORAGE_CUSTOM" }} - {{ $alternative_storage := (getenv "VARNISHD_STORAGE_CUSTOM") }} +{{ else if getenv "VARNISHD_SECONDARY_STORAGE" }} + {{ $alternative_storage := (getenv "VARNISHD_SECONDARY_STORAGE") }} {{ end }} From aaad137a2ebff991af73e0a8d23a3217260a3c78 Mon Sep 17 00:00:00 2001 From: Marlon Saglia Date: Thu, 3 May 2018 08:45:04 +0200 Subject: [PATCH 3/5] Change priority of secondary storage --- 4/templates/varnishd.init.d.tpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/4/templates/varnishd.init.d.tpl b/4/templates/varnishd.init.d.tpl index 22c2545..fb74508 100755 --- a/4/templates/varnishd.init.d.tpl +++ b/4/templates/varnishd.init.d.tpl @@ -7,10 +7,10 @@ if [[ -n "${DEBUG}" ]]; then fi {{ $alternative_storage := false }} -{{ if getenv "VARNISHD_STORAGE_SIZE" }} - {{ $alternative_storage := (printf "file,/var/lib/varnish/storage.bin,%s" (getenv "VARNISHD_STORAGE_SIZE")) }} -{{ else if getenv "VARNISHD_SECONDARY_STORAGE" }} +{{ if getenv "VARNISHD_SECONDARY_STORAGE" }} {{ $alternative_storage := (getenv "VARNISHD_SECONDARY_STORAGE") }} +{{ else if getenv "VARNISHD_STORAGE_SIZE" }} + {{ $alternative_storage := (printf "file,/var/lib/varnish/storage.bin,%s" (getenv "VARNISHD_STORAGE_SIZE")) }} {{ end }} From 32dbaeb02b725bc2039bf6abf3793d08fd1ff3c1 Mon Sep 17 00:00:00 2001 From: Marlon Saglia Date: Thu, 3 May 2018 08:45:47 +0200 Subject: [PATCH 4/5] Change secondary storage variable for consistent naming --- 4/templates/varnishd.init.d.tpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/4/templates/varnishd.init.d.tpl b/4/templates/varnishd.init.d.tpl index fb74508..5afaa8b 100755 --- a/4/templates/varnishd.init.d.tpl +++ b/4/templates/varnishd.init.d.tpl @@ -6,11 +6,11 @@ if [[ -n "${DEBUG}" ]]; then set -x fi -{{ $alternative_storage := false }} +{{ $secondary_storage := false }} {{ if getenv "VARNISHD_SECONDARY_STORAGE" }} - {{ $alternative_storage := (getenv "VARNISHD_SECONDARY_STORAGE") }} + {{ $secondary_storage := (getenv "VARNISHD_SECONDARY_STORAGE") }} {{ else if getenv "VARNISHD_STORAGE_SIZE" }} - {{ $alternative_storage := (printf "file,/var/lib/varnish/storage.bin,%s" (getenv "VARNISHD_STORAGE_SIZE")) }} + {{ $secondary_storage := (printf "file,/var/lib/varnish/storage.bin,%s" (getenv "VARNISHD_STORAGE_SIZE")) }} {{ end }} @@ -22,7 +22,7 @@ exec varnishd \ -f {{ getenv "VARNISHD_VCL_SCRIPT" "/etc/varnish/default.vcl" }} \ -S {{ getenv "VARNISHD_SECRET_FILE" "/etc/varnish/secret" }} \ -s main=malloc,{{ getenv "VARNISHD_MEMORY_SIZE" "64M" }} \ - {{ if $alternative_storage }} -s secondary={{ $alternative_storage }} {{ end }}\ + {{ if $secondary_storage }} -s secondary={{ $secondary_storage }} {{ end }}\ -t {{ getenv "VARNISHD_DEFAULT_TTL" "120" }} \ -p ban_lurker_age={{ getenv "VARNISHD_PARAM_BAN_LURKER_AGE" "60.000" }} \ -p ban_lurker_batch={{ getenv "VARNISHD_PARAM_BAN_LURKER_BATCH" "1000" }} \ From eeb364198a92fbbcc0104910357aa5077eb3f642 Mon Sep 17 00:00:00 2001 From: Marlon Saglia Date: Mon, 7 May 2018 08:41:01 +0200 Subject: [PATCH 5/5] Drop VARNISHD_STORAGE_SIZE in favour of VARNISHD_SECONDARY_STORAGE as discussed in wodby/varnish#4 --- 4/templates/varnishd.init.d.tpl | 10 +--------- README.md | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/4/templates/varnishd.init.d.tpl b/4/templates/varnishd.init.d.tpl index 5afaa8b..356fa29 100755 --- a/4/templates/varnishd.init.d.tpl +++ b/4/templates/varnishd.init.d.tpl @@ -6,14 +6,6 @@ if [[ -n "${DEBUG}" ]]; then set -x fi -{{ $secondary_storage := false }} -{{ if getenv "VARNISHD_SECONDARY_STORAGE" }} - {{ $secondary_storage := (getenv "VARNISHD_SECONDARY_STORAGE") }} -{{ else if getenv "VARNISHD_STORAGE_SIZE" }} - {{ $secondary_storage := (printf "file,/var/lib/varnish/storage.bin,%s" (getenv "VARNISHD_STORAGE_SIZE")) }} -{{ end }} - - exec varnishd \ -j unix,user=varnish \ -F \ @@ -22,7 +14,7 @@ exec varnishd \ -f {{ getenv "VARNISHD_VCL_SCRIPT" "/etc/varnish/default.vcl" }} \ -S {{ getenv "VARNISHD_SECRET_FILE" "/etc/varnish/secret" }} \ -s main=malloc,{{ getenv "VARNISHD_MEMORY_SIZE" "64M" }} \ - {{ if $secondary_storage }} -s secondary={{ $secondary_storage }} {{ end }}\ + {{ if getenv "VARNISHD_SECONDARY_STORAGE" }} -s secondary={{ getenv "VARNISHD_SECONDARY_STORAGE" }} {{ end }}\ -t {{ getenv "VARNISHD_DEFAULT_TTL" "120" }} \ -p ban_lurker_age={{ getenv "VARNISHD_PARAM_BAN_LURKER_AGE" "60.000" }} \ -p ban_lurker_batch={{ getenv "VARNISHD_PARAM_BAN_LURKER_BATCH" "1000" }} \ diff --git a/README.md b/README.md index a76ebd4..5cd34ca 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ Supported tags and respective `Dockerfile` links: | `VARNISHD_PARAM_WORKSPACE_SESSION` | `0.50k` | | | `VARNISHD_PARAM_WORKSPACE_THREAD` | `2k` | | | `VARNISHD_SECRET_FILE` | `/etc/varnish/secret` | | -| `VARNISHD_STORAGE_SIZE` | | | +| `VARNISHD_SECONDARY_STORAGE` | | | | `VARNISHD_VCL_SCRIPT` | `/etc/varnish/default.vcl` | | ## Orchestration Actions