aboutsummaryrefslogtreecommitdiffstats
path: root/main/varnish/varnishd.initd
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2012-08-21 14:35:28 +0300
committerTimo Teräs <timo.teras@iki.fi>2012-08-21 14:36:58 +0300
commiteb55626bb2ba19f3ae9911a82709dc9c994c8389 (patch)
treefa59321d1c6e1b4ae90ad73c848b5b9fe55a2171 /main/varnish/varnishd.initd
parentfd5b60a8060f5116f5778db9c199ec54a423fc51 (diff)
downloadaports-eb55626bb2ba19f3ae9911a82709dc9c994c8389.tar.bz2
aports-eb55626bb2ba19f3ae9911a82709dc9c994c8389.tar.xz
main/varnish: fix varnishd.initd reload, add flush
* vcl.use does not take config file name * discard old, no longer used configs * add flush command to purge cache using appropriate ban
Diffstat (limited to 'main/varnish/varnishd.initd')
-rwxr-xr-xmain/varnish/varnishd.initd28
1 files changed, 22 insertions, 6 deletions
diff --git a/main/varnish/varnishd.initd b/main/varnish/varnishd.initd
index a10e219a8e..b8c565317c 100755
--- a/main/varnish/varnishd.initd
+++ b/main/varnish/varnishd.initd
@@ -3,7 +3,7 @@
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/www-servers/varnish/files/varnishd.initd,v 1.7 2009/08/30 06:28:07 hollow Exp $
-extra_commands=reload
+extra_commands="reload flush"
depend() {
need net
@@ -36,9 +36,25 @@ stop() {
}
reload() {
- ebegin "Reloading varnish"
- NOW=`date +%s`
- /usr/bin/varnishadm -T $ADMINHOSTPORT vcl.load reload$NOW $CFG_FILE
- /usr/bin/varnishadm -T $ADMINHOSTPORT vcl.use reload$NOW $CFG_FILE
- eend $?
+ ebegin "Reloading varnish"
+
+ # purge unused old configurations
+ DISCARDS=$(/usr/bin/varnishadm -T $ADMINHOSTPORT vcl.list |
+ sed -ne "s/^available *0 *\(reload.*\)/ \\1/p")
+ for VCL in $DISCARDS ; do
+ /usr/bin/varnishadm -T $ADMINHOSTPORT vcl.discard $VCL > /dev/null
+ done
+
+ # reload new one
+ NOW=$(date +%Y%m%d-%H%M%S-%s)
+ /usr/bin/varnishadm -T $ADMINHOSTPORT vcl.load reload-$NOW $CFG_FILE > /dev/null
+ /usr/bin/varnishadm -T $ADMINHOSTPORT vcl.use reload-$NOW > /dev/null
+
+ eend $?
+}
+
+flush() {
+ ebegin "Flushing varnish cache"
+ /usr/bin/varnishadm -T $ADMINHOSTPORT ban obj.http.host "~" "." > /dev/null
+ eend $?
}