Back to home page

Redis cross reference

 
 

    


0001 #!/bin/sh
0002 #
0003 # Simple Redis init.d script conceived to work on Linux systems
0004 # as it does use of the /proc filesystem.
0005 
0006 REDISPORT=6379
0007 EXEC=/usr/local/bin/redis-server
0008 CLIEXEC=/usr/local/bin/redis-cli
0009 
0010 PIDFILE=/var/run/redis_${REDISPORT}.pid
0011 CONF="/etc/redis/${REDISPORT}.conf"
0012 
0013 case "$1" in
0014     start)
0015         if [ -f $PIDFILE ]
0016         then
0017                 echo "$PIDFILE exists, process is already running or crashed"
0018         else
0019                 echo "Starting Redis server..."
0020                 $EXEC $CONF
0021         fi
0022         ;;
0023     stop)
0024         if [ ! -f $PIDFILE ]
0025         then
0026                 echo "$PIDFILE does not exist, process is not running"
0027         else
0028                 PID=$(cat $PIDFILE)
0029                 echo "Stopping ..."
0030                 $CLIEXEC -p $REDISPORT shutdown
0031                 while [ -x /proc/${PID} ]
0032                 do
0033                     echo "Waiting for Redis to shutdown ..."
0034                     sleep 1
0035                 done
0036                 echo "Redis stopped"
0037         fi
0038         ;;
0039     *)
0040         echo "Please use start or stop as first argument"
0041         ;;
0042 esac