Created
December 18, 2009 12:24
-
-
Save antirez/259466 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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