Created
April 18, 2011 11:39
-
-
Save v1nc3ntlaw/925168 to your computer and use it in GitHub Desktop.
redis_init_script
This file contains 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 | |
REDIS_PORT=6379 | |
REDIS_EXEC=/usr/local/bin/redis-server | |
REDIS_CLI=/usr/local/bin/redis-cli | |
REDIS_CONF=/etc/redis.conf | |
PIDFILE=/var/run/redis.pid | |
case "$1" in | |
start) | |
if [ -f $PIDFILE ] | |
then | |
echo -e "$PIDFILE exists, process is already running or crashed\n" | |
else | |
echo -e "Starting Redis server..." | |
$REDIS_EXEC $REDIS_CONF | |
fi | |
;; | |
stop) | |
if [ ! -f $PIDFILE ] | |
then | |
echo -e "$PIDFILE does not exist, process is not running\n" | |
else | |
PID=$(cat $PIDFILE) | |
$REDIS_CLI -p $REDIS_PORT "shutdown" | |
echo "Redis stopped" | |
fi | |
;; | |
restart|force-reload) | |
${0} stop | |
${0} start | |
;; | |
*) | |
echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment