2010-01-11 10:15:54 +00:00
|
|
|
#!/bin/sh
|
2011-06-14 11:48:49 +00:00
|
|
|
#
|
|
|
|
# Simple Redis init.d script conceived to work on Linux systems
|
|
|
|
# as it does use of the /proc filesystem.
|
2010-01-11 10:15:54 +00:00
|
|
|
|
|
|
|
REDISPORT=6379
|
|
|
|
EXEC=/usr/local/bin/redis-server
|
2011-06-14 11:48:49 +00:00
|
|
|
CLIEXEC=/usr/local/bin/redis-cli
|
2010-01-11 10:15:54 +00:00
|
|
|
|
|
|
|
PIDFILE=/var/run/redis_${REDISPORT}.pid
|
|
|
|
CONF="/etc/redis/${REDISPORT}.conf"
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
if [ -f $PIDFILE ]
|
|
|
|
then
|
2011-06-14 11:48:49 +00:00
|
|
|
echo "$PIDFILE exists, process is already running or crashed"
|
2010-01-11 10:15:54 +00:00
|
|
|
else
|
2011-06-14 11:48:49 +00:00
|
|
|
echo "Starting Redis server..."
|
2010-01-11 10:15:54 +00:00
|
|
|
$EXEC $CONF
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
if [ ! -f $PIDFILE ]
|
|
|
|
then
|
2011-06-14 11:48:49 +00:00
|
|
|
echo "$PIDFILE does not exist, process is not running"
|
2010-01-11 10:15:54 +00:00
|
|
|
else
|
2011-06-14 11:48:49 +00:00
|
|
|
PID=$(cat $PIDFILE)
|
|
|
|
echo "Stopping ..."
|
|
|
|
$CLIEXEC -p $REDISPORT shutdown
|
2010-01-11 10:15:54 +00:00
|
|
|
while [ -x /proc/${PIDFILE} ]
|
|
|
|
do
|
|
|
|
echo "Waiting for Redis to shutdown ..."
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
echo "Redis stopped"
|
|
|
|
fi
|
|
|
|
;;
|
2011-06-14 11:48:49 +00:00
|
|
|
*)
|
|
|
|
echo "Please use start or stop as first argument"
|
|
|
|
;;
|
2010-01-11 10:15:54 +00:00
|
|
|
esac
|