aboutsummaryrefslogtreecommitdiffstats
path: root/testing/twemproxy/nutcracker.initd
blob: 76d120a779ab06e22b80fc8e3908387989d3a5d8 (plain)
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
#!/sbin/openrc-run

NAME="nutcracker"
DAEMON=/usr/sbin/nutcracker
USER="${USER:-nobody}"
CONFFILE="${CONFFILE:-/etc/nutcracker/nutcracker.yml}"

DAEMON_ARGS=${DAEMON_ARGS:-"-c $CONFFILE -o $LOGFILE -p $PIDFILE -d"}

depend() {
	need net
	after firewall
}

checkconf() {
	ebegin "Testing configuration: "
		${DAEMON} --test-conf \
		--conf-file=${CONFFILE} \
		>/dev/null 2>&1
	eend $?
}


start() {
	checkconf || exit 1
	ebegin "Starting ${NAME}: "
		start-stop-daemon --start --quiet \
			--pidfile ${PIDFILE} \
			--chuid ${USER}:${USER} \
			--exec ${DAEMON} -- ${DAEMON_ARGS}
	eend $?
}

stop() {
	ebegin "Stopping ${NAME}: "
		start-stop-daemon --stop --quiet \
			--pidfile ${PIDFILE} \
			--exec ${DAEMON}
	eend $?
}