aboutsummaryrefslogtreecommitdiff
path: root/www/varnish/files/varnishd.in
blob: 61512f1ce8e355e9882c0d3598ff72f7e2afb63e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: varnishd
# REQUIRE: DAEMON
# KEYWORD: shutdown

#
# Add the following line to /etc/rc.conf to enable varnishd:
#
# varnishd_enable="YES"
#
# Configuration variables and their default values:
#
# varnishd_pidfile - full path to the PID file.
#	default: "/var/run/varnishd.pid"
#
# varnishd_listen - address and port at which varnishd will listen for
#	client requests.
#	default: ":80"
#
# varnishd_admin - address and port at which varnishd will listen for
#	administrative commands.
#	default: "localhost:81"
#
# varnishd_backend - address of the backend server.
#	default: "localhost:8080"
#
# varnishd_config - name of the varnishd config file.
#	default: unset.
#
# varnishd_hash - hash algorithm
#       default: "classic,16383"
#
# varnishd_storage - storage method and parameters.
#	default: "file,/tmp,50%"
#
# varnishd_user - unprivileged user for the child process.
#	default: "www"
#
# varnishd_group - unprivileged group for the child process.
#	default: "www"
#
# varnishd_flags - complete command line arguments.
#	default if varnishd_config is unset: "-P ${varnishd_pidfile} -a ${varnishd_listen} -T ${varnishd_admin} -b ${varnishd_backend} -s ${varnishd_storage} -h ${varnishd_hash} -u ${varnishd_user} -g ${varnishd_group}"
#	default if varnishd_config is set: "-P ${varnishd_pidfile} -a ${varnishd_listen} -T ${varnishd_admin} -f ${varnishd_config} -s ${varnishd_storage} -h ${varnishd_hash} -u ${varnishd_user} -g ${varnishd_group}"
#
# See varnishd(1) for a detailed overview of command-line options.
#

. /etc/rc.subr

name="varnishd"
rcvar=varnishd_enable

command="%%PREFIX%%/sbin/${name}"

# read configuration and set defaults
load_rc_config ${name}
: ${varnishd_enable:="NO"}
: ${varnishd_pidfile:="/var/run/${name}.pid"}
: ${varnishd_listen:=":80"}
: ${varnishd_admin:="localhost:81"}
: ${varnishd_backend:="localhost:8080"}
: ${varnishd_storage:="file,/tmp,50%"}
: ${varnishd_hash:="classic,16383"}
: ${varnishd_user:="www"}
: ${varnishd_group:="www"}
if [ -n "${varnishd_config}" ] ; then
	: ${varnishd_flags:="-P ${varnishd_pidfile} -a ${varnishd_listen} -T ${varnishd_admin} -f ${varnishd_config} -s ${varnishd_storage} -h ${varnishd_hash} -u ${varnishd_user} -g ${varnishd_group}"}
else
	: ${varnishd_flags:="-P ${varnishd_pidfile} -a ${varnishd_listen} -T ${varnishd_admin} -b ${varnishd_backend} -s ${varnishd_storage} -h ${varnishd_hash} -u ${varnishd_user} -g ${varnishd_group}"}
fi

# If we leave these set, rc.subr will su to them before starting
# varnishd, which is not what we want.
unset varnishd_user
unset varnishd_group

pidfile="${varnishd_pidfile}"
run_rc_command "$1"