]>
Commit | Line | Data |
---|---|---|
a69a0c9c | 1 | #!/bin/sh |
2 | ||
3 | REDISPORT=6379 | |
4 | EXEC=/usr/local/bin/redis-server | |
5 | ||
6 | PIDFILE=/var/run/redis_${REDISPORT}.pid | |
7 | CONF="/etc/redis/${REDISPORT}.conf" | |
8 | ||
9 | case "$1" in | |
10 | start) | |
11 | if [ -f $PIDFILE ] | |
12 | then | |
13 | echo -n "$PIDFILE exists, process is already running or crashed\n" | |
14 | else | |
15 | echo -n "Starting Redis server...\n" | |
16 | $EXEC $CONF | |
17 | fi | |
18 | ;; | |
19 | stop) | |
20 | if [ ! -f $PIDFILE ] | |
21 | then | |
22 | echo -n "$PIDFILE does not exist, process is not running\n" | |
23 | else | |
7f9a4db3 | 24 | PID=$(cat $PIDFILE) |
a69a0c9c | 25 | echo -n "Stopping ...\n" |
7f9a4db3 | 26 | echo -n "SHUTDOWN\r\n" | nc localhost $REDISPORT & |
a69a0c9c | 27 | while [ -x /proc/${PIDFILE} ] |
28 | do | |
29 | echo "Waiting for Redis to shutdown ..." | |
30 | sleep 1 | |
31 | done | |
a69a0c9c | 32 | echo "Redis stopped" |
33 | fi | |
34 | ;; | |
35 | esac |