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.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1431 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent a78498d3
# Configuration file for varnish # Configuration file for varnish
#
# /etc/init.d/varnish expects the variable $DAEMON_OPTS to be set from this
# Main configuration file. You probably want to change it :) # shell script fragment.
VARNISH_VCL_CONF=/etc/varnish/vcl.conf #
# Default address and port to bind to # This file contains 4 alternatives, please use only one.
VARNISH_LISTEN_ADDRESS=0.0.0.0
VARNISH_LISTEN_PORT=6081 ## Alternative 1, Minimal configuration, no VCL
#
# Listen on localhost:6081, administration on localhost:6082, and forward to
# Telnet admin interface listen address and port # content server on localhost:8080. Use a fixed size file storage.
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1 #
VARNISH_ADMIN_LISTEN_PORT=6082 DAEMON_OPTS="-a localhost:6081 \
-T localhost:6082 \
-b localhost:8080 \
# The minimum number of threads to start -s file,/var/lib/varnish/varnish_storage.bin,10485760"
VARNISH_MIN_WORKER_THREADS=1
## Alternative 2, Configuration with VCL
# Maximum number of worker threads or INF for unlimited #
VARNISH_MAX_WORKER_THREADS=2048 # 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.
# Timeout value in seconds for threads to return #
VARNISH_WORKER_THREAD_TIMEOUT=10 # DAEMON_OPTS="-a localhost:6081 \
# -T localhost:6082 \
# -f /etc/varnish/default.vcl \
# Hash algorithm to be used # -s file,/var/lib/varnish/varnish_storage.bin,10485760"
VARNISH_HASHOPTION=classic
## Alternative 3, Advanced configuration
# Maximum size of the backend storagefile in bytes #
VARNISH_BACKEND_STORAGE_SIZE=10240000 # See varnishd(1) for more information.
VARNISH_BACKEND_STORAGE_FILE=/var/lib/varnish/varnish_storage.bin #
# # Main configuration file. You probably want to change it :)
# VARNISH_VCL_CONF=/etc/varnish/default.vcl
# Backend storage specification #
VARNISH_BACKEND_STORAGE="file,${VARNISH_BACKEND_STORAGE_FILE},${VARNISH_BACKEND_STORAGE_SIZE}" # # Default address and port to bind to
# VARNISH_LISTEN_ADDRESS=0.0.0.0
# VARNISH_LISTEN_PORT=6081
# Set default ttl in secounds #
VARNISH_TTL=120 #
# # 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}"
#
## Alternative 4, Do It Yourself
#
# DAEMON_OPTS=""
#! /bin/sh #! /bin/sh
# #
# skeleton example file to build /etc/init.d/ scripts. # varnish Control the varnish HTTP accelerator
# This file should be used to construct scripts for /etc/init.d.
#
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
# Modified for Debian
# by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl
#
### BEGIN INIT INFO ### BEGIN INIT INFO
# Provides: varnish # Provides: varnish
# Required-Start: $local_fs $network # Required-Start: $local_fs $network
# Required-Stop: $local_fs $network # Required-Stop: $local_fs $network
# Should-Start: $remote_fs
# Should-Stop: $remote_fs
# Default-Start: 2 3 4 5 # Default-Start: 2 3 4 5
# Default-Stop: 0 1 6 # Default-Stop: 0 1 6
# Short-Description: Start HTTPd accelerator # Short-Description: Start HTTP accelerator
# Description: This script provides a server-side cache # Description: This script provides a server-side cache
# to be run in front of a httpd and should # 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 # system
### END INIT INFO ### END INIT INFO
NAME=varnish # Source function library
DESC="HTTPd accelerator" . /lib/lsb/init-functions
NAME=varnishd
DESC="HTTP accelerator"
PATH=/sbin:/bin:/usr/sbin:/usr/bin PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/varnishd DAEMON=/usr/sbin/varnishd
PIDFILE=/var/run/$NAME.pid
test -x $DAEMON || exit 0 test -x $DAEMON || exit 0
...@@ -37,45 +31,44 @@ if [ -f /etc/default/varnish ] ; then ...@@ -37,45 +31,44 @@ if [ -f /etc/default/varnish ] ; then
. /etc/default/varnish . /etc/default/varnish
fi fi
DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \ # If $DAEMON_OPTS is not set at all in /etc/default/varnish, use minimal useful
-h ${VARNISH_HASHOPTION} \ # defaults (Backend at localhost:8080, a common place to put a locally
-f ${VARNISH_VCL_CONF} \ # installed application server.)
-T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \ DAEMON_OPTS=${DAEMON_OPTS:--b localhost}
-t ${VARNISH_TTL} \
-w ${VARNISH_MIN_WORKER_THREADS},${VARNISH_MAX_WORKER_THREADS},${VARNISH_WORKER_THREAD_TIMEOUT} \
-s ${VARNISH_BACKEND_STORAGE}"
set -e
case "$1" in case "$1" in
start) start)
echo -n "Starting $DESC: " output=$(/bin/tempfile -s.varnish)
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \ log_daemon_msg "Starting $DESC"
--exec $DAEMON -- $DAEMON_OPTS 2>&1 > /dev/null log_progress_msg $NAME
echo "$NAME." if start-stop-daemon \
;; --start --quiet --pidfile ${PIDFILE} --exec ${DAEMON} -- \
stop) -P ${PIDFILE} ${DAEMON_OPTS} > ${output} 2>&1; then
echo -n "Stopping $DESC: " log_end_msg 0
pkill varnishd else
echo "$NAME." log_end_msg 1
;; cat $output
restart|force-reload) fi
# rm $output
# If the "reload" option is implemented, move the "force-reload" ;;
# option to the "reload" entry above. If not, "force-reload" is stop)
# just the same as "restart". log_daemon_msg "Stopping $DESC"
# log_progress_msg $NAME
echo -n "Restarting $DESC: " if start-stop-daemon \
pkill varnishd --stop --quiet --pidfile $PIDFILE --oknodo --retry 10 \
sleep 1 --exec $DAEMON; then
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \ log_end_msg 0
--exec $DAEMON -- $DAEMON_OPTS 2>&1 > /dev/null else
echo "$NAME." log_end_msg 1
;; fi
*) ;;
N=/etc/init.d/$NAME restart|force-reload)
echo "Usage: $N {start|stop|restart|force-reload}" >&2 $0 stop
exit 1 $0 start
;;
*)
log_success_msg "Usage: $0 {start|stop|restart|force-reload}"
exit 1
;; ;;
esac esac
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment