-
Notifications
You must be signed in to change notification settings - Fork 1
/
redis_sentinel.init.j2
75 lines (68 loc) · 1.92 KB
/
redis_sentinel.init.j2
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
#!/bin/sh
#
# Redis Sentinel init script for RHEL-based distros
#
# chkconfig: - 58 74
# description: Redis Sentinel monitor
#
# Source function library
. /etc/init.d/functions
SENTINEL_PORT={{ redis_sentinel_port }}
NAME="sentinel_${SENTINEL_PORT}"
if [ -r /etc/sysconfig/sentinel_${SENTINEL_PORT} ]; then
. /etc/sysconfig/sentinel_${SENTINEL_PORT}
fi
REDIS_USER={{ redis_user }}
BIND_ADDRESS={{ redis_sentinel_bind }}
PIDFILE={{ redis_sentinel_pidfile }}
CONF="/etc/redis/sentinel_${SENTINEL_PORT}.conf"
EXEC={{ redis_install_dir }}/bin/redis-server
CLIEXEC="{{ redis_install_dir }}/bin/redis-cli -p ${SENTINEL_PORT}"
if [ -n "$REDIS_PASSWORD" ]; then
CLIEXEC="${CLIEXEC} -a ${REDIS_PASSWORD}"
fi
if [ -n "$BIND_ADDRESS" ]; then
CLIEXEC="${CLIEXEC} -h ${BIND_ADDRESS}"
fi
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
if [ -n "$NOFILE_LIMIT" ]; then
ulimit -n $NOFILE_LIMIT
fi
echo "Starting Redis Sentinel..."
daemon --user $REDIS_USER $EXEC $CONF --sentinel
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis Sentinel to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
status)
status -p "${PIDFILE}" "sentinel_${SENTINEL_PORT}"
;;
restart|force-reload)
${0} stop
${0} start
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|status|restart|force-reload}" >&2
exit 1
;;
esac
exit 0