Last active
December 11, 2015 02:59
-
-
Save sideshow/4534409 to your computer and use it in GitHub Desktop.
Redis 2.6 init script for ubuntu based on redis sample 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 | |
### BEGIN INIT INFO | |
# Provides: redis-server | |
# Required-Start: $syslog $remote_fs | |
# Required-Stop: $syslog $remote_fs | |
# Should-Start: $local_fs | |
# Should-Stop: $local_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: redis-server - Persistent key-value db | |
# Description: redis-server - Persistent key-value db | |
### END INIT INFO | |
NAME=redis-server | |
DESC=redis-server | |
REDISPORT=6379 | |
EXEC=/usr/local/bin/redis-server | |
CLIEXEC=/usr/local/bin/redis-cli | |
PIDFILE=/var/run/redis.pid | |
CONF="/etc/redis/redis.conf" | |
case "$1" in | |
start) | |
if [ -f $PIDFILE ] | |
then | |
echo "$PIDFILE exists, process is already running or crashed" | |
else | |
echo "Starting Redis server..." | |
$EXEC $CONF | |
fi | |
;; | |
stop) | |
if [ ! -f $PIDFILE ] | |
then | |
echo "$PIDFILE does not exist, process is not running" | |
else | |
PID=$(cat $PIDFILE) | |
echo "Stopping ..." | |
$CLIEXEC -p $REDISPORT shutdown | |
while [ -x /proc/${PID} ] | |
do | |
echo "Waiting for Redis to shutdown ..." | |
sleep 1 | |
done | |
echo "Redis stopped" | |
fi | |
;; | |
*) | |
echo "Please use start or stop as first argument" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment