#!/bin/sh
REDISPORT=6666
EXEC=./redis-server
CLIEXEC=./redis-cli
AUTHPASSWD='Passwd_By_Zjq;' # 如果设置了密码,这里是需要设置的,因为利用redis-cli 发送shutdown信号需要提供密码。
PIDFILE=/ghca/redis/bin/redis_${REDISPORT}.pid
CONF="/ghca/redis/etc/redis.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -a $AUTHPASSWD -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac