-
Notifications
You must be signed in to change notification settings - Fork 22
/
redis-cluster
executable file
·91 lines (83 loc) · 2.01 KB
/
redis-cluster
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
84
85
86
87
88
89
90
91
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-cluster
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog $remote_fs
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-cluster - a cluster of Persistent key-value db
# Description: redis-cluster - a cluster Persistent key-value db
### END INIT INFO
###########VARIABLES START########
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/redis-server
NAME=redis-cluster
DESC=redis-cluster
CONFDIR=/usr/local/etc/redis
PIDDIR=/var/run
NODENO=8
###########VARIABLES END##########
####conf files in the form "redis-node-1.conf, redis-node-2.conf...."
test -x $DAEMON || exit 0
set -e
case "$1" in
start)
i=0
while [ $i != $NODENO ]; do
i=`expr $i + 1`
NODENAME="redis-node-$i"
echo -n "Starting ${NODENAME}: "
PIDFILE=${PIDDIR}/${NODENAME}.pid
touch ${PIDFILE}
chown redis:redis ${PIDFILE}
if start-stop-daemon --start --quiet --umask 007 --pidfile ${PIDFILE} --chuid redis:redis --exec $DAEMON -- ${CONFDIR}/${NODENAME}.conf
then
echo "success."
else
echo "failed"
fi
done
;;
stop)
i=0
while [ $i != $NODENO ]; do
i=`expr $i + 1`
NODENAME="redis-node-$i"
echo -n "Stopping ${NODENAME}: "
PIDFILE=${PIDDIR}/${NODENAME}.pid
if start-stop-daemon --stop --retry 10 --quiet --oknodo --pidfile ${PIDFILE} --exec $DAEMON
then
echo "success."
else
echo "failed"
fi
rm -f ${PIDFILE}
done
;;
restart|force-reload)
${0} stop
${0} start
;;
status)
i=0
while [ $i != $NODENO ]; do
i=`expr $i + 1`
NODENAME="redis-node-$i"
echo -n "${NODENAME} is "
PIDFILE=${PIDDIR}/${NODENAME}.pid
if start-stop-daemon --stop --quiet --signal 0 --name ${NODENAME} --pidfile ${PIDFILE}
then
echo "running"
else
echo "not running"
fi
done
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0