diff options
author | Matt Schurenko <matt.schurenko@gmail.com> | 2011-10-09 03:44:57 -0500 |
---|---|---|
committer | Robby Workman <rworkman@slackbuilds.org> | 2011-10-11 21:20:30 -0500 |
commit | 2b7c9cd06c6963ffae8087b1cce75a96b963073a (patch) | |
tree | aab1a080e4ec604f7310807c3f1650da240e14c8 /network/varnish/rc.varnishd | |
parent | d237cb9dbda73bda305912e90b48f244e2c6bbec (diff) |
network/varnish: Added (a state of the art web application accelerator)
Signed-off-by: Erik Hanson <erik@slackbuilds.org>
Diffstat (limited to 'network/varnish/rc.varnishd')
-rwxr-xr-x | network/varnish/rc.varnishd | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/network/varnish/rc.varnishd b/network/varnish/rc.varnishd new file mode 100755 index 0000000000000..b6354687f7fcc --- /dev/null +++ b/network/varnish/rc.varnishd @@ -0,0 +1,78 @@ +#!/bin/sh + +# varnish rc script +# written by Matt Schurenko <matt.schurenko@gmail.com> + +USAGE="usage: $0 start|stop|restart" +BIN='/usr/sbin/varnishd' +CONF='/etc/varnish/default.vcl' +PID='/var/run/varnish.pid' + +## +# adjust the following variables accordingly +## +BACKING_FILE='/var/lib/varnish-cache' +ADMIN_IP='127.0.0.1' +ADMIN_PORT=8001 +HTTP_IP='0.0.0.0' +HTTP_PORT=80 +CACHE_SIZE='1g' +# ttl assigned to objects without ttl values (default 120s) +DEFAULT_TTL=604800 # 7 days +FILE_DESCRIPTORS=131072 +MIN_THREADS=5 +MAX_THREADS=500 +THREAD_TIMEOUT=300 +# maximum number of http headers (default is 64) +HTTP_HEADERS=384 +# connection timout for backend (default is 0.4s) +CONNECT_TIMEOUT='4.0' + +VARNISH_OPTS="-f $CONF \ + -s file,${BACKING_FILE},$CACHE_SIZE \ + -T $ADMIN_IP:${ADMIN_PORT} \ + -a $HTTP_IP:${HTTP_PORT} \ + -t $DEFAULT_TTL \ + -w${MIN_THREADS},${MAX_THREADS},${THREAD_TIMEOUT} \ + -P $PID" + +VARNISH_PARAMS="-p http_headers=$HTTP_HEADERS \ + -p connect_timeout=$CONNECT_TIMEOUT" + +varnish_start() { + if [ -e $PID ];then + if [ `pgrep varnishd|head -n1` == `cat $PID` ];then + echo "varnish is already running" + exit 1 + else # pid file must be stale + "$PID exists but pid doesn't match pid of varnishd. please investigate." + exit 2 + fi + fi + ulimit -n $FILE_DESCRIPTORS + echo "starting varnish..." + $BIN $VARNISH_OPTS $VARNISH_PARAMS +} +varnish_stop() { + echo "stopping varnish..." + killall `echo $BIN | awk -F'/' '{print $NF}'` + if [ -e $PID ];then + rm $PID + fi +} + +case "$1" in + start) + varnish_start + ;; + stop) + varnish_stop + ;; + restart) + varnish_stop + sleep 1 + varnish_start + ;; + *) echo -e $USAGE + ;; +esac |