aboutsummaryrefslogtreecommitdiffstats
path: root/main/varnish
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2016-04-14 08:59:08 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2016-04-14 09:03:30 +0000
commite59b4743337fdb0dc950ce9d1f03a9c747472b63 (patch)
tree1fc1dc47564822632445b43494bc31f9d014c8cd /main/varnish
parent0126ba3d84d35779e1ff8a0b5eb0d1162b37796a (diff)
downloadaports-e59b4743337fdb0dc950ce9d1f03a9c747472b63.tar.bz2
aports-e59b4743337fdb0dc950ce9d1f03a9c747472b63.tar.xz
main/varnish: sync with openrc scripts from gentoo
Diffstat (limited to 'main/varnish')
-rw-r--r--main/varnish/APKBUILD52
-rw-r--r--main/varnish/varnishd.confd38
-rw-r--r--main/varnish/varnishd.initd133
-rw-r--r--main/varnish/varnishd.logrotate38
-rw-r--r--main/varnish/varnishlog.confd3
-rw-r--r--main/varnish/varnishlog.initd32
-rw-r--r--main/varnish/varnishncsa.confd3
-rw-r--r--main/varnish/varnishncsa.initd45
8 files changed, 207 insertions, 137 deletions
diff --git a/main/varnish/APKBUILD b/main/varnish/APKBUILD
index 61bd3a1c5f..ae957e5351 100644
--- a/main/varnish/APKBUILD
+++ b/main/varnish/APKBUILD
@@ -3,7 +3,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=varnish
pkgver=4.1.2
-pkgrel=1
+pkgrel=2
pkgdesc="High-performance HTTP accelerator"
url="http://www.varnish-cache.org/"
arch="all"
@@ -23,6 +23,10 @@ source="http://repo.varnish-cache.org/source/varnish-$pkgver.tar.gz
varnishd.initd
varnishd.confd
+ varnishlog.initd
+ varnishlog.confd
+ varnishncsa.initd
+ varnishncsa.confd
varnishd.logrotate
maxminddb.vcl
"
@@ -57,18 +61,22 @@ build() {
package() {
cd "$_builddir"
make DESTDIR="$pkgdir" install || return 1
- install -Dm755 "$srcdir"/varnishd.initd "$pkgdir"/etc/init.d/varnishd \
- || return 1
- install -Dm644 "$srcdir"/varnishd.confd "$pkgdir"/etc/conf.d/varnishd \
- || return 1
+ for i in $source; do
+ case $i in
+ *.initd) install -Dm755 "$srcdir"/$i \
+ "$pkgdir"/etc/init.d/${i%.*} || return 1 ;;
+ *.confd) install -Dm644 "$srcdir"/$i \
+ "$pkgdir"/etc/conf.d/${i%.*} || return 1 ;;
+ esac
+ done
install -Dm644 "$srcdir"/varnishd.logrotate \
"$pkgdir"/etc/logrotate.d/varnishd || return 1
- install -d -o varnish -g varnish \
+ install -d -o varnish -g varnish -m750 \
"$pkgdir"/var/cache/varnish \
"$pkgdir"/var/log/varnish \
"$pkgdir"/var/lib/varnish \
|| return 1
- install -d "$pkgdir"/etc/varnish || return 1
+ install -d -o root -g varnish -m750 "$pkgdir"/etc/varnish || return 1
}
libs() {
@@ -88,23 +96,35 @@ md5sums="51d446c0193dd773f5a881f7c0beb304 varnish-4.1.2.tar.gz
2fec4f98c892e07d97d93a7bb8529fea fix-compat-execinfo.patch
c942796a1359c9b7e0a5a53d16db476e fix-stack-overflow.patch
54d12d231c505c95ae3ae09487b5dde4 musl-mode_t.patch
-a3d78275f93f59fd4ebad1d09fc41c9e varnishd.initd
-1ed5a6de82e6204400229fa79a54d9a7 varnishd.confd
-a6cb8a43c9465699cf956dc992998225 varnishd.logrotate
+698e7376fa224ebdf052acd7dd8c8a82 varnishd.initd
+73f89f154632bc21c9256ecca0ebf3d1 varnishd.confd
+fa0be78eca165a032bc975e809eac0c4 varnishlog.initd
+9e4ef776683286f6fe54385b577773a9 varnishlog.confd
+39138c65e88ed4f8efb659a39d98d6d8 varnishncsa.initd
+fbe42d5da63b4567a7cfa0ecb7df8d3c varnishncsa.confd
+acd003fbcd1d8607508960e13c5ede85 varnishd.logrotate
2cbaa46b9da9f78ecf4c906730f7c5e3 maxminddb.vcl"
sha256sums="9728da944d28eb5be90e7ab6799c2c4c831ef4df5e5154537eb7f2e5d5e348c4 varnish-4.1.2.tar.gz
66a281c03bcf0c01bc8215fe39a3b6a593751fb2034824b471596d517554e183 fix-compat-execinfo.patch
a58d9c5dd2c1a0e9883d58ddec684993bc9fe6e91132c99b00c82a1c4228e647 fix-stack-overflow.patch
f96b6dab0e68e169cffceb63776e312d8585bc2a46dfcc5fa2b1ec5e953ad624 musl-mode_t.patch
-fda5d424ecb2279195ab85bb9c834fe59999fa9b753cad61d5475520e98263dc varnishd.initd
-c252697811103e9846069b4d4de750105d79960a289ea1f7fcf1e99f682fb5dc varnishd.confd
-017173cb42bb60f853063b7fbc843120c547e501233ce2299e1066b5d81e4d5e varnishd.logrotate
+d8a2dffca49df2867824ef71f9aacb05ad4f2803da979621e67433df989d022d varnishd.initd
+bc29e1a65f1712e414479323bfb88833e86ad277e03ac87c892a32d959917a4e varnishd.confd
+553292b71e489a84058b84ff06f14cc6f6cce5c735b3566eb7ef4b7aa4241f61 varnishlog.initd
+e285fe31434addbeee40c6fae7745536574750a0fe658788318acb33943e38d3 varnishlog.confd
+ae6eff8b0a3a4c35f9227e244e7dc06f5a3fdf625d1fc524bbc6965e3f9aacfb varnishncsa.initd
+60e03274b8d786abf7769be26a4ee6c671a155a761b16ee92d5c8b183491870e varnishncsa.confd
+4c1b7abf23bfc32a65f65633c0be0d065fb9fee72e4b533feca35c596d9c5a2c varnishd.logrotate
fd6c810a6099b1b0c2eb572aec239e3f51debc52a6c32fce715f265d7b1a1f85 maxminddb.vcl"
sha512sums="28c4e5a3a74bf5294e6d1f7a48cd3ec64faffca89388b7ea9ed3de3cd58bede357383bcdd021ff783a411590c0a0a1cb747981507272352c1521b4fcac35e179 varnish-4.1.2.tar.gz
e4c3b8fe85ccb3f37c69561b981f89c757acc5534379afec551b7eabc2fe8661e3566513f4bfea9192af8576fc587b34170008f5818038c17c412ac64b27cf51 fix-compat-execinfo.patch
d07a187f5e17644d724b1b555506f65bd9e0a23084d0f4dbb836ec6cc1f1585b6e2d8b3818543823f60dcc3089a0466e08c627c9518ed178238580ec3996caef fix-stack-overflow.patch
8758bef9039a2cca23b7302668bd49f1ea07f54835512a8a9558bb9ed5de1c0fca53f2085ccd298fe0c6579fc81c3b583a85f4f6b25b6ad85f89bf3be04afb70 musl-mode_t.patch
-146387f493fb2323e7720fa495fca101ea7435ac8e4b57c8f7a02f2d9c7faedb1188465fb4a59a67600cf8b3c9cce9946cd52e31c1d348c2a5f042c1eeb21226 varnishd.initd
-f2b4f88c1cea5d8576bf5c6ea82ee841c1fa9dd10daaef668c262669c2d3bc9d151f3c491f8678717047cf0d161c25b4104dd4d29bc8ddb44dd749b7f58c39e7 varnishd.confd
-8fb1cba86ede5eff28a494f6b1da1a651d66383cdeb63922104407f28903dea0c643155b6d7ac8353b8c63d480a6c5b43a70c7252bc51ee73317c33a1844c52c varnishd.logrotate
+5f9cd1da8a72e71d6317d9c9b625d4b2f4f46ff6c4f7aaf8fed5958ce141be572d7e4d2d207af51b1cf4201b19b9bc1574d3cfcf7616c043a309c04ce6ae949e varnishd.initd
+98c8901e53f3c6adb908b9eb01fd441ea53f3c54d4a79aecb1fb1eddfa2fc93de3d0de403a4464a9baff15873b3a20623837e3a37cb225e924a329e32b9e37d6 varnishd.confd
+31758d5b328700d31cf078efce64421ab7b6f00961733b990367efa8ce9aa406e72b46be1cf21fe2f8e11e3cc1803dc9158930ae7803131a88d71f7193d2d270 varnishlog.initd
+88fe9b545a2b25d6e6e45f1cfecbeca5f503bc1fbe95856386e568edee41b487b162cddceba8cb152b0a37d8d96635a76c0715fc69d87d6c667ac403ebae0bb7 varnishlog.confd
+d620dd5ad8b81c561ff395fcf0307df9d4b49ef34b5d4322f461e570ffce58fea687365017b27cb6fde8c41b554750bb913fd1337764fdc16f1513429ee3d9fb varnishncsa.initd
+a5426ff66b89d2afb6273f05e4117b3eec5ce0162a624d52c92b418960f72e58bd01224165613221af76ec241bd98e1eb985b2ef7b83a5b615e9ece67234dcc8 varnishncsa.confd
+51cc6d46ff7439de93977ab87dfb0af399458c1e446475696f73342ae7a0c1a8ca8fc6e79e593659f1af30716a5f8a1ee5e3b1f5e7b35df40b45d47e7b0f2ffd varnishd.logrotate
69f088819cff6d4441813be284f4117f232d08908515bd15d96bd5bb9d41ba7100657a52fd408d44c396d004366062ae22fbf08e2a983cd8023b554539ccf596 maxminddb.vcl"
diff --git a/main/varnish/varnishd.confd b/main/varnish/varnishd.confd
index b51eda6be5..1a18b64854 100644
--- a/main/varnish/varnishd.confd
+++ b/main/varnish/varnishd.confd
@@ -1,32 +1,18 @@
# /etc/conf.d/varnishd
+VARNISHD="/usr/sbin/varnishd"
+VARNISHADM="/usr/bin/varnishadm"
-# Varnish configuration file
-# VARNISH_CONF="/etc/varnish/default.vcl"
+#CONFIGFILES="/etc/varnish/${SVCNAME}.vcl"
+CONFIGFILE="/etc/varnish/default.vcl"
-VARNISH_SECRET_FILE="/etc/varnish/secret"
+# Listen on 127.0.0.1:8080 and connect to backend 127.0.0.1:80
+#VARNISHD_OPTS="-a 127.0.0.1:8080 -a 127.0.0.1:8080"
-# Varnish address
-VARNISH_LISTEN_ADDRESS=
-VARNISH_PORT=8080
-
-# Varnish storage
-VARNISH_STORAGE_FILE="/var/cache/varnish/varnish_storage.bin"
-VARNISH_STORAGE_SIZE=50M
-VARNISH_STORAGE="file,${VARNISH_STORAGE_FILE},${VARNISH_STORAGE_SIZE}"
-# VARNISH_STORAGE="malloc,${VARNISH_STORAGE_SIZE}"
-
-# Varnish admin
-ADMINHOSTPORT="127.0.0.1:65080"
-
-# If maxminddb.vcl is included, this adds the proper library support
-# VARNISHD_PLUGIN_CFLAGS="-lmaxminddb"
-
-# options passed to varnish on startup
-# please see the varnishd man page for more options
-VARNISHD_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_PORT} -s ${VARNISH_STORAGE} -T $ADMINHOSTPORT"
-
-# arguments passed to varnishncsa
-# please see the varnishncsa man page for more options
-VARNISHNCSA_ARGS="-a -w /var/log/varnish/${SVCNAME}.log"
+# Alternatively, don't listen to a backend
+VARNISHD_OPTS="-a 127.0.0.1:8080"
+# You may need to increase the number of open files (-n)
+# and the maximum amount off locked memory (-l)
+# See bug #459142
+#rc_ulimit="-n 32786 -l 82000"
diff --git a/main/varnish/varnishd.initd b/main/varnish/varnishd.initd
index 1aaa989d3e..b0ec918bb7 100644
--- a/main/varnish/varnishd.initd
+++ b/main/varnish/varnishd.initd
@@ -1,36 +1,23 @@
-#!/sbin/openrc-run
-# Copyright 1999-2006 Gentoo Foundation
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/www-servers/varnish/files/varnishd.initd,v 1.7 2009/08/30 06:28:07 hollow Exp $
+# $Id$
-extra_commands="configtest"
-extra_started_commands="reload flush"
-command=/usr/sbin/varnishd
+VARNISHD_PID=${VARNISHD_PID:-/run/${SVCNAME}.pid}
+CONFIGFILES="${CONFIGFILE:-/etc/varnish/default.vcl}"
-instance=${SVCNAME#*.}
-instance_opt="-n $instance"
-if [ "$instance" = "$SVCNAME" ]; then
- instance=""
- instance_opt=""
-fi
+command="${VARNISHD:-/usr/sbin/varnishd}"
+command_args="-j unix,user=varnish -P ${VARNISHD_PID} -f ${CONFIGFILE} ${VARNISHD_OPTS}"
+pidfile="${VARNISHD_PID}"
-default_conf="${instance:-default}.vcl"
-: ${VARNISH_CONF:=${CFG_FILE:-"/etc/varnish/$default_conf"}}
-: ${VARNISHD_PID_FILE:="/var/run/varnish/${SVCNAME}.pid"}
-: ${VARNISHD_CC_COMMAND:="exec cc -fpic -shared -Wl,-x ${VARNISHD_PLUGIN_CFLAGS} -o %o %s"}
-: ${VARNISHNCSA_PID_FILE:="/var/run/varnish/varnishncsa${instance:+.}${instance}.pid"}
+extra_commands="configtest"
+extra_started_commands="reload"
+description_configtest="Run syntax tests for configuration files."
+description_reload="Reloads the configuration."
depend() {
need net
- after firewall
-}
-
-checkconfig() {
- if ! $command -C -f ${VARNISH_CONF} -p "cc_command=${VARNISHD_CC_COMMAND}" >/dev/null 2>&1; then
- error "$SVCNAME has deteced an error in your setup:"
- $command -C -f ${VARNISH_CONF}
- fi
}
configtest() {
@@ -39,56 +26,24 @@ configtest() {
eend $?
}
-start() {
- checkconfig || return 1
- ebegin "Starting ${SVCNAME}"
- checkpath --directory --owner varnish:varnish \
- --mode 755 ${VARNISHD_PID_FILE%/*}
- #allow varnishd to lock logfile to memory
- ulimit -l 82000
- start-stop-daemon --quiet --start \
- --pidfile ${VARNISHD_PID_FILE} \
- --exec $command \
- -- \
- -j unix,user=varnish \
- -f ${VARNISH_CONF} \
- -P ${VARNISHD_PID_FILE} \
- -p "cc_command=${VARNISHD_CC_COMMAND}" \
- $instance_opt \
- ${VARNISHD_OPTS} &> /dev/null
- eend $?
-
- if [ "${VARNISHNCSA_ARGS}" != "" ]; then
- # wait for varnish to start up
- timeout=50
- while [ $timeout -gt 0 ]; do
- /usr/bin/varnishadm 'vcl.list' >/dev/null 2>&1 && break
- sleep 0.1
- timeout=$(( $timeout - 1 ))
- done
-
- ebegin "Starting varnish logging"
- start-stop-daemon --quiet --start \
- --pidfile ${VARNISHNCSA_PID_FILE} \
- --exec /usr/bin/varnishncsa \
- -- \
- -D -P ${VARNISHNCSA_PID_FILE} \
- $instance_opt \
- ${VARNISHNCSA_ARGS}
- eend $?
+checkconfig() {
+ ${VARNISHD} -C -f ${CONFIGFILE} >/dev/null 2>&1
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eerror "${SVCNAME} has detected an error in your setup:"
+ ${VARNISHD} -C -f ${CONFIGFILE}
fi
+
+ return $ret
}
-stop() {
- ebegin "Stopping varnish"
- start-stop-daemon --quiet --stop --pidfile ${VARNISHD_PID_FILE}
- eend $?
+start_pre() {
+ checkconfig || return 1
+}
- if [ -e ${VARNISHNCSA_PID_FILE} ]; then
- ebegin "Stopping varnish logging"
- start-stop-daemon --quiet --stop \
- --pidfile ${VARNISHNCSA_PID_FILE}
- eend $?
+stop_pre() {
+ if [ "${RC_CMD}" = "restart" ]; then
+ checkconfig || return 1
fi
}
@@ -97,23 +52,27 @@ reload() {
ebegin "Reloading varnish"
- # purge unused old configurations
- DISCARDS=$(/usr/bin/varnishadm -T $ADMINHOSTPORT vcl.list |
- sed -ne "s/^available *0 *\(reload.*\)/ \\1/p")
- for VCL in $DISCARDS ; do
- /usr/bin/varnishadm -T $ADMINHOSTPORT vcl.discard $VCL > /dev/null
- done
+ $VARNISHADM vcl.list >/dev/null 2>&1
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eerror "${SVCNAME} cannot list configuration"
+ return 1
+ fi
- # reload new one
- NOW=$(date +%Y%m%d-%H%M%S-%s)
- /usr/bin/varnishadm -T $ADMINHOSTPORT vcl.load reload-$NOW ${VARNISH_CONF} > /dev/null
- /usr/bin/varnishadm -T $ADMINHOSTPORT vcl.use reload-$NOW > /dev/null
+ new_config="reload_$(date +%FT%H:%M:%S)"
+ $VARNISHADM vcl.load $new_config $CONFIGFILE >/dev/null 2>&1
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eerror "${SVCNAME} cannot load configuration"
+ return 1
+ fi
- eend $?
-}
+ $VARNISHADM vcl.use $new_config >/dev/null 2>&1
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eerror "${SVCNAME} cannot switch configuration"
+ return 1
+ fi
-flush() {
- ebegin "Flushing varnish cache"
- /usr/bin/varnishadm -T $ADMINHOSTPORT ban obj.http.host "~" "." > /dev/null
- eend $?
+ eend 0
}
diff --git a/main/varnish/varnishd.logrotate b/main/varnish/varnishd.logrotate
index 62ee60007a..e697e428f3 100644
--- a/main/varnish/varnishd.logrotate
+++ b/main/varnish/varnishd.logrotate
@@ -1,9 +1,31 @@
-/var/log/varnish/*.log {
- weekly
- rotate 10
- copytruncate
- delaycompress
- compress
- notifempty
- missingok
+/var/log/varnish/varnishncsa.log {
+ daily
+ rotate 31
+ copytruncate
+ dateext
+ dateyesterday
+ delaycompress
+ compress
+ notifempty
+ missingok
+
+ prerotate
+ /etc/init.d/varnishncsa -q status && /etc/init.d/varnishncsa -q flush
+ endscript
+}
+
+/var/log/varnish/varnishlog.log {
+ daily
+ rotate 31
+ copytruncate
+ dateext
+ dateyesterday
+ delaycompress
+ compress
+ notifempty
+ missingok
+
+ prerotate
+ /etc/init.d/varnishlog -q status && /etc/init.d/varnishlog -q flush
+ endscript
}
diff --git a/main/varnish/varnishlog.confd b/main/varnish/varnishlog.confd
new file mode 100644
index 0000000000..d7358b1dc8
--- /dev/null
+++ b/main/varnish/varnishlog.confd
@@ -0,0 +1,3 @@
+# /etc/conf.d/varnishlog
+
+VARNISHLOG_OPTS="-a -w /var/log/varnish/varnishlog.log"
diff --git a/main/varnish/varnishlog.initd b/main/varnish/varnishlog.initd
new file mode 100644
index 0000000000..fae8297743
--- /dev/null
+++ b/main/varnish/varnishlog.initd
@@ -0,0 +1,32 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+VARNISHLOG_PID=${VARNISHLOG_PID:-/run/${SVCNAME}.pid}
+
+command="${VARNISHLOG:-/usr/bin/varnishlog}"
+command_args="-D -P ${VARNISHLOG_PID} ${VARNISHLOG_OPTS}"
+pidfile="${VARNISHLOG_PID}"
+
+extra_started_commands="reload rotate flush"
+
+description_rotate="Rotate the log file"
+description_flush="Flush any outstanding transactions"
+
+rotate() {
+ ebegin "Rotating log file"
+ start-stop-daemon -p ${VARNISHLOG_PID} -s SIGHUP
+ eend $?
+}
+
+flush() {
+ ebegin "Flushing any outstanding transactions"
+ start-stop-daemon -p ${VARNISHLOG_PID} -s SIGUSR1
+ eend $?
+}
+
+reload() {
+ flush
+ rotate
+}
diff --git a/main/varnish/varnishncsa.confd b/main/varnish/varnishncsa.confd
new file mode 100644
index 0000000000..f3112fdd53
--- /dev/null
+++ b/main/varnish/varnishncsa.confd
@@ -0,0 +1,3 @@
+# /etc/conf.d/varnishncsa
+
+VARNISHNCSA_OPTS="-a -w /var/log/varnish/${SVCNAME}.log"
diff --git a/main/varnish/varnishncsa.initd b/main/varnish/varnishncsa.initd
new file mode 100644
index 0000000000..e06a5945af
--- /dev/null
+++ b/main/varnish/varnishncsa.initd
@@ -0,0 +1,45 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+VARNISHNCSA_PID=${VARNISHNCSA_PID:-/run/${SVCNAME}.pid}
+
+command="${VARNISHNCSA:-/usr/bin/varnishncsa}"
+command_args="-D -P ${VARNISHNCSA_PID} ${VARNISHNCSA_OPTS}"
+pidfile="${VARNISHNCSA_PID}"
+
+extra_started_commands="reload rotate flush"
+
+description_rotate="Rotate the log file"
+description_flush="Flush any outstanding transactions"
+
+# We need to make sure varnishd has started first, bug #524284
+start_pre() {
+ TIMEOUT=${TIMEOUT:-5}
+
+ local i=0
+ while [ $i -lt ${TIMEOUT} ]; do
+ echo status | varnishadm 2>/dev/null | grep -q "Child in state running"
+ test $? -eq 0 && break
+
+ sleep 1 && i=$(expr $i + 1)
+ done
+}
+
+rotate() {
+ ebegin "Rotating log file"
+ start-stop-daemon -p ${VARNISHNCSA_PID} -s SIGHUP
+ eend $?
+}
+
+flush() {
+ ebegin "Flushing any outstanding transactions"
+ start-stop-daemon -p ${VARNISHNCSA_PID} -s SIGUSR1
+ eend $?
+}
+
+reload() {
+ flush
+ rotate
+}