diff options
author | root <root@rshg054.dnsready.net> | 2011-12-30 23:14:51 +0000 |
---|---|---|
committer | root <root@rshg054.dnsready.net> | 2011-12-30 23:14:51 +0000 |
commit | 5d738f85840804ee493d267784d9cce5dc52f535 (patch) | |
tree | 646f79576fee9f326fa833f7ca480d2355056556 /extra/varnish/rc.varnish | |
parent | 8a823402bd45dc875237a20f174ecbe64e1bae4d (diff) |
Fri Dec 30 23:14:51 UTC 2011
Diffstat (limited to 'extra/varnish/rc.varnish')
-rw-r--r-- | extra/varnish/rc.varnish | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/extra/varnish/rc.varnish b/extra/varnish/rc.varnish index 2ebd97e33..4e4fde60d 100644 --- a/extra/varnish/rc.varnish +++ b/extra/varnish/rc.varnish @@ -4,6 +4,27 @@ . /etc/rc.d/functions . /etc/conf.d/varnish +reload_vcl() { + local activecfg newcfg + + if [[ -z $VARNISH_CFG ]]; then + printf '==> ERROR: VARNISH_CFG is undefined in /etc/conf.d/varnish!\n' + return 1 + fi + + activecfg=$(varnishadm -T localhost:6082 "vcl.list" | awk '/active/{ print $3 }') + if [[ -z $activecfg ]]; then + printf '==> ERROR: No active VCL found!\n' + return 1 + fi + + printf -v newcfg 'vcl-%(%s)T' -1 + + varnishadm -T localhost:6082 "vcl.load $newcfg $VARNISH_CFG" && + varnishadm -T localhost:6082 "vcl.use $newcfg" && + varnishadm -T localhost:6082 "vcl.discard $activecfg" || return 1 +} + pidfile=/run/varnish.pid if [[ -r $pidfile ]]; then read -r PID < "$pidfile" @@ -40,6 +61,10 @@ case "$1" in sleep 1 $0 start ;; + reload) + stat_busy "Recompiling and Reloading VCL" + reload_vcl && stat_done || stat_fail + ;; *) echo "usage: $0 {start|stop|restart}" ;; |