summaryrefslogtreecommitdiff
path: root/dev-db/redis/files/redis.initd
blob: 337ca6e7fcb321873815243e386d60e7ae485ba3 (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
#!/sbin/runscript
# $Header: /var/cvsroot/gentoo-x86/dev-db/redis/files/redis.initd,v 1.4 2012/02/04 21:17:55 swegener Exp $

REDIS_EXEC=/usr/sbin/redis-server
REDIS_PID=${REDIS_PID:-/var/run/redis/redis.pid}
REDIS_DIR=${REDIS_DIR:-/var/lib/redis}
REDIS_CONF=${REDIS_CONF:-/etc/redis.conf}
REDIS_OPTS=${REDIS_OPTS:-"${REDIS_CONF}"}
REDIS_USER=${REDIS_USER:-redis}
REDIS_GROUP=${REDIS_GROUP:-redis}

depend() {
	use net localmount logger
	after keepalived
}

start() {

	local PID_DIR=$(dirname ${REDIS_PID})
	mkdir -p ${PID_DIR}
	chown ${REDIS_USER}:${REDIS_GROUP} ${PID_DIR}

	ebegin "Starting Redis server"
	start-stop-daemon --start \
		--chdir "${REDIS_DIR}" \
		--user ${REDIS_USER}:${REDIS_GROUP} \
		--pidfile "${REDIS_PID}" \
		--exec "${REDIS_EXEC}" \
		-- ${REDIS_OPTS}
	ret=$?
	eend ${ret}

}

stop() {
	ebegin "Stopping Redis server"
	start-stop-daemon --stop --quiet --pidfile "${REDIS_PID}"
	ret=$?
	rm -f "${REDIS_PID}"
	eend ${ret}
}