2011-10-03 08:48:07 +00:00
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
2012-05-04 11:07:00 +00:00
|
|
|
if [ -f $PIDFILE ]
|
2011-10-03 08:48:07 +00:00
|
|
|
then
|
2014-03-15 13:43:50 +00:00
|
|
|
echo "$PIDFILE exists, process is already running or crashed"
|
2011-10-03 08:48:07 +00:00
|
|
|
else
|
2014-03-15 13:43:50 +00:00
|
|
|
echo "Starting Redis server..."
|
|
|
|
$EXEC $CONF
|
2011-10-03 08:48:07 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
if [ ! -f $PIDFILE ]
|
|
|
|
then
|
2014-03-15 13:43:50 +00:00
|
|
|
echo "$PIDFILE does not exist, process is not running"
|
2011-10-03 08:48:07 +00:00
|
|
|
else
|
2014-03-15 13:43:50 +00:00
|
|
|
PID=$(cat $PIDFILE)
|
|
|
|
echo "Stopping ..."
|
|
|
|
$CLIEXEC -p $REDISPORT shutdown
|
|
|
|
while [ -x /proc/${PID} ]
|
|
|
|
do
|
|
|
|
echo "Waiting for Redis to shutdown ..."
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
echo "Redis stopped"
|
2011-10-03 08:48:07 +00:00
|
|
|
fi
|
|
|
|
;;
|
2014-03-15 13:43:50 +00:00
|
|
|
status)
|
2014-10-26 18:09:45 +00:00
|
|
|
PID=$(cat $PIDFILE)
|
|
|
|
if [ ! -x /proc/${PID} ]
|
2014-03-15 13:43:50 +00:00
|
|
|
then
|
|
|
|
echo 'Redis is not running'
|
|
|
|
else
|
2014-10-26 18:09:45 +00:00
|
|
|
echo "Redis is running ($PID)"
|
2014-03-15 13:43:50 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
$0 stop
|
|
|
|
$0 start
|
|
|
|
;;
|
2011-10-03 08:48:07 +00:00
|
|
|
*)
|
2014-03-15 13:43:50 +00:00
|
|
|
echo "Please use start, stop, restart or status as first argument"
|
2011-10-03 08:48:07 +00:00
|
|
|
;;
|
|
|
|
esac
|