Skip to content

Instantly share code, notes, and snippets.

@antirez
Created December 18, 2009 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antirez/259466 to your computer and use it in GitHub Desktop.
Save antirez/259466 to your computer and use it in GitHub Desktop.
#!/bin/sh
PIDFILE=/var/run/redis_6379.pid
EXEC=/usr/local/bin/redis-server
CONF="/etc/redis/6379.conf"
REDISPORT=6379
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo -n "$PIDFILE exists, process is already running or crashed\n"
else
echo -n "Starting Redis server...\n"
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo -n "$PIDFILE does not exist, process is not running\n"
else
echo -n "Stopping ...\n"
echo -n "shutdown\r\n" | nc localhost $REDISPORT &
PID=$(cat $PIDFILE)
while [ -x /proc/${PIDFILE} ]
do
echo "Waiting for Redis shutdown ..."
sleep 1
done
rm $PIDFILE
echo "Redis stopped"
fi
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment