]> git.saurik.com Git - redis.git/blame - utils/redis_init_script
Better init script
[redis.git] / utils / redis_init_script
CommitLineData
a69a0c9c 1#!/bin/sh
b0d68504 2#
3# Simple Redis init.d script conceived to work on Linux systems
4# as it does use of the /proc filesystem.
a69a0c9c 5
6REDISPORT=6379
7EXEC=/usr/local/bin/redis-server
b0d68504 8CLIEXEC=/usr/local/bin/redis-cli
a69a0c9c 9
10PIDFILE=/var/run/redis_${REDISPORT}.pid
11CONF="/etc/redis/${REDISPORT}.conf"
12
13case "$1" in
14 start)
15 if [ -f $PIDFILE ]
16 then
b0d68504 17 echo "$PIDFILE exists, process is already running or crashed"
a69a0c9c 18 else
b0d68504 19 echo "Starting Redis server..."
a69a0c9c 20 $EXEC $CONF
21 fi
22 ;;
23 stop)
24 if [ ! -f $PIDFILE ]
25 then
b0d68504 26 echo "$PIDFILE does not exist, process is not running"
a69a0c9c 27 else
b0d68504 28 PID=$(cat $PIDFILE)
29 echo "Stopping ..."
30 $CLIEXEC -p $REDISPORT shutdown
a69a0c9c 31 while [ -x /proc/${PIDFILE} ]
32 do
33 echo "Waiting for Redis to shutdown ..."
34 sleep 1
35 done
a69a0c9c 36 echo "Redis stopped"
37 fi
38 ;;
b0d68504 39 *)
40 echo "Please use start or stop as first argument"
41 ;;
a69a0c9c 42esac