Skip to content

Instantly share code, notes, and snippets.

@midwire
Created July 10, 2014 14:02
Show Gist options
  • Select an option

  • Save midwire/68e89175e0415c5efbcf to your computer and use it in GitHub Desktop.

Select an option

Save midwire/68e89175e0415c5efbcf to your computer and use it in GitHub Desktop.
Varnish service control script
#!/usr/bin/env bash
cmd=$1
PROG=/usr/local/opt/varnish3/sbin/varnishd
VCL=/usr/local/etc/varnish/default.vcl
OPTS="-n /usr/local/var/varnish -f $VCL -s malloc,1G -T localhost:6082 -a :6081"
function start_varnish() {
echo "Running [$PROG $OPTS]"
$PROG $OPTS
}
function stop_varnish() {
pkill varnishd
}
case $cmd in
start )
start_varnish
;;
stop )
stop_varnish
;;
restart )
stop_varnish
start_varnish
;;
status )
x=`redis-cli time`
if [ $? == 0 ]; then
echo "Redis is running."
else
echo "Redis is NOT running."
fi
;;
* )
echo "Usage: $0 [status, start, stop, restart]"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment