r1431 - trunk/varnish-cache/debian

ssm at projects.linpro.no ssm at projects.linpro.no
Wed May 16 13:38:08 CEST 2007


Author: ssm
Date: 2007-05-16 13:38:08 +0200 (Wed, 16 May 2007)
New Revision: 1431

Modified:
   trunk/varnish-cache/debian/varnish.default
   trunk/varnish-cache/debian/varnish.init
Log:
Init-script: 

  * Move user-adjustable parts from init script to defaults file, expect
    $DAEMON_OPTS instead of a whole forest of variables.

  * We have a pid file argument, wheee. :D

Defaults file:

 * Created alternative default templates, selected a one-backend default
   without VCL file.



Modified: trunk/varnish-cache/debian/varnish.default
===================================================================
--- trunk/varnish-cache/debian/varnish.default	2007-05-16 10:59:13 UTC (rev 1430)
+++ trunk/varnish-cache/debian/varnish.default	2007-05-16 11:38:08 UTC (rev 1431)
@@ -1,44 +1,91 @@
 # Configuration file for varnish
+# 
+# /etc/init.d/varnish expects the variable $DAEMON_OPTS to be set from this
+# shell script fragment.
+#
 
+# This file contains 4 alternatives, please use only one.
 
-# Main configuration file. You probably want to change it :)
-VARNISH_VCL_CONF=/etc/varnish/vcl.conf
+## Alternative 1, Minimal configuration, no VCL
+#
+# Listen on localhost:6081, administration on localhost:6082, and forward to
+# content server on localhost:8080.  Use a fixed size file storage.
+#
+DAEMON_OPTS="-a localhost:6081 \
+             -T localhost:6082 \
+	     -b localhost:8080 \
+	     -s file,/var/lib/varnish/varnish_storage.bin,10485760"
 
-# Default address and port to bind to
-VARNISH_LISTEN_ADDRESS=0.0.0.0
-VARNISH_LISTEN_PORT=6081
 
+## Alternative 2, Configuration with VCL
+#
+# Listen on localhost:6081, administration on localhost:6082, and forward to
+# one content server selected by the vcl file, based on the request.  Use a
+# fixed size file storage.
+#
+# DAEMON_OPTS="-a localhost:6081 \
+#              -T localhost:6082 \
+#              -f /etc/varnish/default.vcl \
+#              -s file,/var/lib/varnish/varnish_storage.bin,10485760"
 
-# Telnet admin interface listen address and port
-VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
-VARNISH_ADMIN_LISTEN_PORT=6082
 
+## Alternative 3, Advanced configuration
+#
+# See varnishd(1) for more information.
+# 
+# # Main configuration file. You probably want to change it :)
+# VARNISH_VCL_CONF=/etc/varnish/default.vcl
+# 
+# # Default address and port to bind to
+# VARNISH_LISTEN_ADDRESS=0.0.0.0
+# VARNISH_LISTEN_PORT=6081
+# 
+# 
+# # Telnet admin interface listen address and port
+# VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
+# VARNISH_ADMIN_LISTEN_PORT=6082
+# 
+# 
+# # The minimum number of threads to start
+# VARNISH_MIN_WORKER_THREADS=1
+# 
+# 
+# # Maximum number of worker threads or INF for unlimited
+# VARNISH_MAX_WORKER_THREADS=2048
+# 
+# 
+# # Timeout value in seconds for threads to return
+# VARNISH_WORKER_THREAD_TIMEOUT=10 
+# 
+# 
+# # Hash algorithm to be used
+# VARNISH_HASHOPTION=classic
+# 
+# 
+# # Maximum size of the backend storagefile in bytes
+# VARNISH_BACKEND_STORAGE_SIZE=10240000
+# VARNISH_BACKEND_STORAGE_FILE=/var/lib/varnish/varnish_storage.bin
+# 
+# 
+# # Backend storage specification
+# VARNISH_BACKEND_STORAGE="file,${VARNISH_BACKEND_STORAGE_FILE},${VARNISH_BACKEND_STORAGE_SIZE}"
+# 
+# 
+# # Set default ttl in secounds
+# VARNISH_TTL=120
+# 
+# # DAEMON_OPTS is used by the init script.  If you add or remove options, make
+# # sure you update this section, too.
+# DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
+#              -h ${VARNISH_HASHOPTION} \
+#              -f ${VARNISH_VCL_CONF} \
+#              -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
+#              -t ${VARNISH_TTL} \
+#              -w ${VARNISH_MIN_WORKER_THREADS},${VARNISH_MAX_WORKER_THREADS},${VARNISH_WORKER_THREAD_TIMEOUT} \
+#              -s ${VARNISH_BACKEND_STORAGE}"
+#
 
-# The minimum number of threads to start
-VARNISH_MIN_WORKER_THREADS=1
 
-
-# Maximum number of worker threads or INF for unlimited
-VARNISH_MAX_WORKER_THREADS=2048
-
-
-# Timeout value in seconds for threads to return
-VARNISH_WORKER_THREAD_TIMEOUT=10 
-
-
-# Hash algorithm to be used
-VARNISH_HASHOPTION=classic
-
-
-# Maximum size of the backend storagefile in bytes
-VARNISH_BACKEND_STORAGE_SIZE=10240000
-VARNISH_BACKEND_STORAGE_FILE=/var/lib/varnish/varnish_storage.bin
-
-
-# Backend storage specification
-VARNISH_BACKEND_STORAGE="file,${VARNISH_BACKEND_STORAGE_FILE},${VARNISH_BACKEND_STORAGE_SIZE}"
-
-
-# Set default ttl in secounds
-VARNISH_TTL=120
-
+## Alternative 4, Do It Yourself
+#
+# DAEMON_OPTS=""

Modified: trunk/varnish-cache/debian/varnish.init
===================================================================
--- trunk/varnish-cache/debian/varnish.init	2007-05-16 10:59:13 UTC (rev 1430)
+++ trunk/varnish-cache/debian/varnish.init	2007-05-16 11:38:08 UTC (rev 1431)
@@ -1,34 +1,28 @@
 #! /bin/sh
 #
-# skeleton      example file to build /etc/init.d/ scripts.
-#               This file should be used to construct scripts for /etc/init.d.
-#
-#               Written by Miquel van Smoorenburg <miquels at cistron.nl>.
-#               Modified for Debian 
-#               by Ian Murdock <imurdock at gnu.ai.mit.edu>.
-#
-# Version:      @(#)skeleton  1.9  26-Feb-2001  miquels at cistron.nl
-#
+# varnish       Control the varnish HTTP accelerator
 
 ### BEGIN INIT INFO
 # Provides:          varnish
 # Required-Start:    $local_fs $network
 # Required-Stop:     $local_fs $network
-# Should-Start:      $remote_fs
-# Should-Stop:       $remote_fs
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
-# Short-Description: Start HTTPd accelerator
+# Short-Description: Start HTTP accelerator
 # Description:       This script provides a server-side cache
 #                    to be run in front of a httpd and should
-#		     listen on port 80 on a properly configured
+#                    listen on port 80 on a properly configured
 #                    system
 ### END INIT INFO
 
-NAME=varnish
-DESC="HTTPd accelerator"
+# Source function library
+. /lib/lsb/init-functions
+
+NAME=varnishd
+DESC="HTTP accelerator"
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 DAEMON=/usr/sbin/varnishd
+PIDFILE=/var/run/$NAME.pid
 
 test -x $DAEMON || exit 0
 
@@ -37,46 +31,45 @@
         . /etc/default/varnish
 fi
 
-DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
-		-h ${VARNISH_HASHOPTION} \
-		-f ${VARNISH_VCL_CONF} \
-		-T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
-		-t ${VARNISH_TTL} \
-		-w ${VARNISH_MIN_WORKER_THREADS},${VARNISH_MAX_WORKER_THREADS},${VARNISH_WORKER_THREAD_TIMEOUT} \
-		-s ${VARNISH_BACKEND_STORAGE}"	
+# If $DAEMON_OPTS is not set at all in /etc/default/varnish, use minimal useful
+# defaults (Backend at localhost:8080, a common place to put a locally
+# installed application server.)
+DAEMON_OPTS=${DAEMON_OPTS:--b localhost}
 
-set -e
-
 case "$1" in
-  start)
-        echo -n "Starting $DESC: "
-        start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
-                --exec $DAEMON -- $DAEMON_OPTS 2>&1 > /dev/null
-        echo "$NAME."
+	start)
+		output=$(/bin/tempfile -s.varnish)
+		log_daemon_msg "Starting $DESC" 
+		log_progress_msg $NAME
+                if start-stop-daemon \
+		   --start --quiet --pidfile ${PIDFILE} --exec ${DAEMON} -- \
+                   -P ${PIDFILE} ${DAEMON_OPTS} > ${output} 2>&1; then
+			log_end_msg 0
+		else
+			log_end_msg 1
+			cat $output
+		fi
+		rm $output
+		;;
+	stop)
+		log_daemon_msg "Stopping $DESC"
+		log_progress_msg $NAME
+		if start-stop-daemon \
+		   --stop --quiet --pidfile $PIDFILE --oknodo --retry 10 \
+		   --exec $DAEMON; then
+			log_end_msg 0
+		else
+			log_end_msg 1
+		fi
+        	;;
+	restart|force-reload)
+		$0 stop
+		$0 start
+        	;;
+	*)
+        	log_success_msg "Usage: $0 {start|stop|restart|force-reload}"
+        	exit 1
         ;;
-  stop)
-        echo -n "Stopping $DESC: "
-		pkill varnishd
-        echo "$NAME."
-        ;;
-  restart|force-reload)
-        #
-        #       If the "reload" option is implemented, move the "force-reload"
-        #       option to the "reload" entry above. If not, "force-reload" is
-        #       just the same as "restart".
-        #
-        echo -n "Restarting $DESC: "
-                pkill varnishd
-        sleep 1
-		start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
-		--exec $DAEMON -- $DAEMON_OPTS 2>&1 > /dev/null
-        echo "$NAME."
-        ;;
-  *)
-        N=/etc/init.d/$NAME
-        echo "Usage: $N {start|stop|restart|force-reload}" >&2
-        exit 1
-        ;;
 esac
 
 exit 0




More information about the varnish-commit mailing list