[-]
[+]
|
Changed |
varnish.spec
|
|
[-]
[+]
|
Changed |
redhat-init.tar.bz2/varnish.initrc
^
|
@@ -23,7 +23,7 @@
. /etc/init.d/functions
retval=0
-pidfile=/var/run/varnish.pid
+pidfile=/var/run/varnish/varnish.pid
exec="/usr/sbin/varnishd"
reload_exec="/usr/sbin/varnish_reload_vcl"
|
[-]
[+]
|
Added |
redhat-init.tar.bz2/varnish_reload_vcl
^
|
@@ -0,0 +1,123 @@
+#!/bin/bash
+#
+# reload vcl revisited
+# A script that loads new vcl based on data from /etc/sysconfig/varnish
+# Ingvar Hagelund <ingvar@redpill-linpro.com>
+#
+# This is free software, distributed under the standard 2 clause BSD license,
+# see the LICENSE file in the Varnish documentation directory
+#
+# The following environment variables have to be set:
+# RELOAD_VCL, VARNISH_VCL_CONF, VARNISH_ADMIN_LISTEN_PORT
+# The following are optional:
+# VARNISH_SECRET_FILE, VARNISH_ADMIN_LISTEN_ADDRESS
+#
+# Requires GNU bash and GNU date
+#
+
+debug=false
+
+missing() {
+ echo "Missing configuration variable: $1"
+ exit 2
+}
+
+print_debug() {
+ echo "
+Parsed configuration:
+RELOAD_VCL=\"$RELOAD_VCL\"
+VARNISH_VCL_CONF=\"$VARNISH_VCL_CONF\"
+VARNISH_ADMIN_LISTEN_ADDRESS=\"$VARNISH_ADMIN_LISTEN_ADDRESS\"
+VARNISH_ADMIN_LISTEN_PORT=\"$VARNISH_ADMIN_LISTEN_PORT\"
+VARNISH_SECRET_FILE=\"$VARNISH_SECRET_FILE\"
+"
+}
+
+# Fallback to the default configuration
+if [ -z "$VARNISH_VCL_CONF" ]; then
+ . /etc/sysconfig/varnish
+fi
+
+# Get warmup time from defaults or use 0 warmup
+WARMUP=${WARMUP_TIME:-0}
+
+$debug && print_debug
+
+# Check configuration
+if [ ! "$RELOAD_VCL" = "1" ]; then
+ echo "Error: RELOAD_VCL is not set to 1"
+ exit 2
+
+elif [ -z "$VARNISH_VCL_CONF" ]; then
+ echo "Error: VARNISH_VCL_CONF is not set"
+ exit 2
+
+elif [ ! -s "$VARNISH_VCL_CONF" ]; then
+ echo "Eror: VCL config $VARNISH_VCL_CONF is unreadable or empty"
+ exit 2
+
+elif [ -z "$VARNISH_ADMIN_LISTEN_ADDRESS" ]; then
+ echo "Warning: VARNISH_ADMIN_LISTEN_ADDRESS is not set, using 127.0.0.1"
+ VARNISH_ADMIN_LISTEN_ADDRESS="127.0.0.1"
+
+elif [ -z "$VARNISH_ADMIN_LISTEN_PORT" ]; then
+ echo "Error: VARNISH_ADMIN_LISTEN_PORT is not set"
+ exit 2
+
+elif [ -z "$VARNISH_SECRET_FILE" ]; then
+ echo "Warning: VARNISH_SECRET_FILE is not set"
+ secret=""
+
+elif [ ! -s "$VARNISH_SECRET_FILE" ]; then
+ echo "Error: varnish secret file $VARNISH_SECRET_FILE is unreadable or empty"
+ exit 2
+else
+ secret="-S $VARNISH_SECRET_FILE"
+fi
+
+# Done parsing, set up command
+VARNISHADM="varnishadm $secret -T $VARNISH_ADMIN_LISTEN_ADDRESS:$VARNISH_ADMIN_LISTEN_PORT"
+
+# Now do the real work
+new_config="reload_$(date +%FT%H%M%S)"
+
+# Check if we are able to connect at all
+if $VARNISHADM vcl.list > /dev/null; then
+ $debug && echo vcl.list succeeded
+else
+ echo "Unable to run $VARNISHADM vcl.list"
+ exit 1
+fi
+
+if $VARNISHADM vcl.list | awk ' { print $4 } ' | grep -q $new_config; then
+ echo Trying to use new config $new_config, but that is already in use
+ exit 2
+fi
+
+current_config=$( $VARNISHADM vcl.list | awk ' /^active/ { print $4 } ' )
+
+echo "Loading vcl from $VARNISH_VCL_CONF"
+echo "Current running config name is $current_config"
+echo "Using new config name $new_config"
+
+if $VARNISHADM vcl.load $new_config $VARNISH_VCL_CONF; then
+ $debug && echo "$VARNISHADM vcl.load succeded"
+else
+ echo "$VARNISHADM vcl.load failed"
+ exit 1
+fi
+
+# Wait before vcl.use if WARMUP > 0
+# Used if backend probes require some time to set backends healthy
+sleep $WARMUP
+
+if $VARNISHADM vcl.use $new_config; then
+ $debug && echo "$VARNISHADM vcl.use succeded"
+else
+ echo "$VARNISHADM vcl.use failed"
+ exit 1
+fi
+$VARNISHADM vcl.list
+echo Done
+exit 0
+
|
[-]
[+]
|
Changed |
redhat-init.tar.bz2/varnishncsa.initrc
^
|
@@ -22,7 +22,7 @@
. /etc/init.d/functions
retval=0
-pidfile="/var/run/varnishncsa.pid"
+pidfile="/var/run/varnish/varnishncsa.pid"
lockfile="/var/lock/subsys/varnishncsa"
logfile="/var/log/varnish/varnishncsa.log"
|
[-]
[+]
|
Changed |
varnish.initrc
^
|
@@ -23,7 +23,7 @@
. /etc/init.d/functions
retval=0
-pidfile=/var/run/varnish.pid
+pidfile=/var/run/varnish/varnish.pid
exec="/usr/sbin/varnishd"
reload_exec="/usr/sbin/varnish_reload_vcl"
|
[-]
[+]
|
Changed |
varnishncsa.initrc
^
|
@@ -22,7 +22,7 @@
. /etc/init.d/functions
retval=0
-pidfile="/var/run/varnishncsa.pid"
+pidfile="/var/run/varnish/varnishncsa.pid"
lockfile="/var/lock/subsys/varnishncsa"
logfile="/var/log/varnish/varnishncsa.log"
|