summaryrefslogtreecommitdiff
path: root/utils/redis_init_script
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2011-06-14 13:48:49 +0200
committerantirez <antirez@gmail.com>2011-06-14 13:49:15 +0200
commitb0d68504e9986ffa9f1f80f550a04c4f1898957f (patch)
treefa509748de05defb19d0b14afa6d3318590321dc /utils/redis_init_script
parent4abd096f5188448a2c0e75511a049b3a3fd8e9b1 (diff)
downloadredis-b0d68504e9986ffa9f1f80f550a04c4f1898957f.tar.gz
Better init script
Diffstat (limited to 'utils/redis_init_script')
-rwxr-xr-xutils/redis_init_script19
1 files changed, 13 insertions, 6 deletions
diff --git a/utils/redis_init_script b/utils/redis_init_script
index b1c560022..96da06836 100755
--- a/utils/redis_init_script
+++ b/utils/redis_init_script
@@ -1,7 +1,11 @@
#!/bin/sh
+#
+# Simple Redis init.d script conceived to work on Linux systems
+# as it does use of the /proc filesystem.
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
+CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf"
@@ -10,20 +14,20 @@ case "$1" in
start)
if [ -f $PIDFILE ]
then
- echo -n "$PIDFILE exists, process is already running or crashed\n"
+ echo "$PIDFILE exists, process is already running or crashed"
else
- echo -n "Starting Redis server...\n"
+ echo "Starting Redis server..."
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
- echo -n "$PIDFILE does not exist, process is not running\n"
+ echo "$PIDFILE does not exist, process is not running"
else
- PID=$(cat $PIDFILE)
- echo -n "Stopping ...\n"
- echo -n "SHUTDOWN\r\n" | nc localhost $REDISPORT &
+ PID=$(cat $PIDFILE)
+ echo "Stopping ..."
+ $CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PIDFILE} ]
do
echo "Waiting for Redis to shutdown ..."
@@ -32,4 +36,7 @@ case "$1" in
echo "Redis stopped"
fi
;;
+ *)
+ echo "Please use start or stop as first argument"
+ ;;
esac