Skip to content

Instantly share code, notes, and snippets.

@q0rban
Created January 8, 2012 15:38
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save q0rban/1578738 to your computer and use it in GitHub Desktop.
Save q0rban/1578738 to your computer and use it in GitHub Desktop.
Varnish Reload VCL Script
#!/bin/bash
# Reload a varnish config
# Author: Kristian Lyngstol
FILE="/etc/varnish/ugc.vcl"
# Hostname and management port
# (defined in /etc/default/varnish or on startup)
HOSTPORT="localhost:6082"
NOW=`date +%s`
SECRET='/etc/varnish/secret'
NAME=$1
if [ -z "$NAME" ]
then
NAME="reload$NOW"
fi
error()
{
echo 1>&2 "Failed to reload $FILE."
exit 1
}
varnishadm -T $HOSTPORT -S $SECRET vcl.load $NAME $FILE || error
varnishadm -T $HOSTPORT -S $SECRET vcl.use $NAME || error
echo Current configs:
varnishadm -T $HOSTPORT -S $SECRET vcl.list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment