Kristian's web log

February 18, 2009

Easy reloading of varnish’ VCL

Filed under: Varnish — Tags: , , — kristian @ 15:43

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).

#!/bin/bash
# Reload a varnish config
# Author: Kristian Lyngstol

FILE="/etc/varnish/default.vcl"

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

error()
{
    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

3 Comments »

  1. [...] Not wanting to telnet or use varnishadm manually, this script does the trick. This was taken from http://kristian.blog.linpro.no/2009/02/18/easy-reloading-of-varnish-vcl/: #!/bin/bash # Reload a varnish config # Author: Kristian Lyngstol   [...]

    Pingback by The road to Elysium / Easy reloading of Varnish — May 27, 2009 @ 08:24

  2. Great little script man. Cheers.

    Comment by Travis Bell — September 30, 2009 @ 03:46

  3. [...] varnishreload From http://kristian.blog.linpro.no/2009/02/18/easy-reloading-of-varnish-vcl/ , this is a very handy script you can use to reload varnish’s configuration without having to [...]

    Pingback by Linux: Handy Varnish commands > Richy's Random Ramblings — November 29, 2009 @ 14:53

RSS feed for comments on this post. TrackBack URL

Leave a comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Powered by WordPress