Kristian Lyngstøl's Blog

Easy reloading of varnish' VCL

Posted on 2009-02-18

One thing I do regularly is reload the default VCL that Varnish use, and to avoid using telnet or varnishadm manually, I've written a tiny script that loads and uses default.vcl (or any other file, for that matter).

# Reload a varnish config
# Author: Kristian Lyngstol


# Hostname and management port
# (defined in /etc/default/varnish or on startup)
NOW=`date +%s`

echo 1>&2 "Failed to reload $FILE."
exit 1

varnishadm -T $HOSTPORT vcl.load reload$NOW $FILE || error
varnishadm -T $HOSTPORT vcl.use reload$NOW || error
echo Current configs:
varnishadm -T $HOSTPORT vcl.list