代码语言:javascript复制
#!/bin/sh
# redis脚本运行在Linux系统
# chkconfig: 2345 10 90
# description: redis service
EXEC="/usr/local/redis/bin/redis-sentinel"
CLIEXEC="/usr/local/redis/bin/redis-cli"
PIDFILE="/usr/local/redis/logs/sentinel-26379.pid"
CONF="/usr/local/redis/conf/sentinel.conf"
start(){
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
if [ "$?"="0" ]
then
echo "Redis is running..."
fi
}
stop(){
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
kill ${PID}
sleep 1
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
}
restart(){
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo "用法: /etc/init.d/redis {start|stop|status|start}"
exit 1
esac