2011-10-24 12:48:58 +02:00
|
|
|
Index: utils/redis_init_script
|
|
|
|
===================================================================
|
|
|
|
--- utils/redis_init_script.orig 2011-10-17 10:46:00.000000000 +0200
|
|
|
|
+++ utils/redis_init_script 2011-10-24 12:47:43.108960720 +0200
|
|
|
|
@@ -1,42 +1,75 @@
|
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
-# Simple Redis init.d script conceived to work on Linux systems
|
|
|
|
-# as it does use of the /proc filesystem.
|
|
|
|
+# /etc/init.d/redis
|
|
|
|
+#
|
|
|
|
+### BEGIN INIT INFO
|
|
|
|
+# Provides: redis
|
|
|
|
+# Required-Start: $syslog $remote_fs
|
|
|
|
+# Should-Start:
|
|
|
|
+# Required-Stop: $syslog $remote_fs
|
|
|
|
+# Should-Stop:
|
2011-11-24 11:50:39 +01:00
|
|
|
+# Default-Start: 3 5
|
2011-10-24 12:48:58 +02:00
|
|
|
+# Default-Stop: 0 1 2 6
|
|
|
|
+# Short-Description: Redis server
|
|
|
|
+# Description: Starts and stops the Redis daemon
|
|
|
|
+### END INIT INFO
|
|
|
|
+
|
|
|
|
+. /etc/rc.status
|
|
|
|
|
|
|
|
REDISPORT=6379
|
|
|
|
-EXEC=/usr/local/bin/redis-server
|
|
|
|
-CLIEXEC=/usr/local/bin/redis-cli
|
|
|
|
+EXEC=/usr/sbin/redis-server
|
|
|
|
+CLIEXEC=/usr/bin/redis-cli
|
|
|
|
|
|
|
|
-PIDFILE=/var/run/redis_${REDISPORT}.pid
|
|
|
|
-CONF="/etc/redis/${REDISPORT}.conf"
|
|
|
|
+CONF=/etc/redis.conf
|
|
|
|
+PIDFILE=/var/run/redis.pid
|
|
|
|
+LOGFILE=/var/log/redis/redis.log
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
- if [ -f $PIDFILE ]
|
|
|
|
- then
|
|
|
|
- echo "$PIDFILE exists, process is already running or crashed"
|
|
|
|
- else
|
|
|
|
- echo "Starting Redis server..."
|
|
|
|
- $EXEC $CONF
|
|
|
|
+ if [ ! -r $LOGFILE ]; then
|
|
|
|
+ touch $LOGFILE
|
|
|
|
+ chown redis:redis $LOGFILE
|
|
|
|
+ fi
|
|
|
|
+ # Create a pidfile the server can write into.
|
|
|
|
+ if [ ! -r $PIDFILE ]; then
|
|
|
|
+ touch $PIDFILE
|
|
|
|
+ chown redis:redis $PIDFILE
|
|
|
|
fi
|
|
|
|
+ echo -n "Starting service Redis "
|
|
|
|
+ /sbin/startproc -u redis -g redis -p $PIDFILE -s -e $EXEC $CONF >/dev/null 2>&1
|
|
|
|
+ rc_status -v
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
if [ ! -f $PIDFILE ]
|
|
|
|
then
|
|
|
|
- echo "$PIDFILE does not exist, process is not running"
|
|
|
|
+ echo -n "$PIDFILE does not exist, process is not running"
|
|
|
|
+ rc_failed
|
|
|
|
else
|
|
|
|
- PID=$(cat $PIDFILE)
|
|
|
|
- echo "Stopping ..."
|
|
|
|
+ echo -n "Stopping service Redis..."
|
|
|
|
$CLIEXEC -p $REDISPORT shutdown
|
|
|
|
- while [ -x /proc/${PID} ]
|
|
|
|
+ PID=$(cat $PIDFILE)
|
|
|
|
+ while [ -x /proc/${PIDFILE} ]
|
|
|
|
do
|
|
|
|
- echo "Waiting for Redis to shutdown ..."
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
- echo "Redis stopped"
|
|
|
|
fi
|
|
|
|
+ rc_status -v
|
|
|
|
;;
|
|
|
|
- *)
|
|
|
|
- echo "Please use start or stop as first argument"
|
|
|
|
+ restart)
|
|
|
|
+ $0 stop
|
|
|
|
+ $0 start
|
|
|
|
;;
|
|
|
|
+ reload)
|
|
|
|
+ $0 restart
|
|
|
|
+ ;;
|
|
|
|
+ status)
|
|
|
|
+ echo -n "Checking for service Redis: "
|
|
|
|
+ /sbin/checkproc -p $PIDFILE $EXEC
|
|
|
|
+ rc_status -v
|
|
|
|
+ ;;
|
|
|
|
+ *)
|
|
|
|
+ echo $"Usage: $0 {start|stop|status|restart|reload}"
|
|
|
|
+ exit 1
|
|
|
|
esac
|
|
|
|
+rc_exit
|
|
|
|
+
|