84 lines
2.3 KiB
Diff
84 lines
2.3 KiB
Diff
Index: utils/redis_init_script
|
|
===================================================================
|
|
--- utils/redis_init_script.orig
|
|
+++ utils/redis_init_script
|
|
@@ -1,36 +1,67 @@
|
|
#!/bin/sh
|
|
+### BEGIN INIT INFO
|
|
+# Provides: redis
|
|
+# Required-Start: $syslog $remote_fs
|
|
+# Should-Start:
|
|
+# Required-Stop: $syslog $remote_fs
|
|
+# Should-Stop:
|
|
+# Default-Start: 3 5
|
|
+# Default-Stop: 0 1 2 6
|
|
+# Short-Description: Redis server
|
|
+# Description: Manages the Redis server
|
|
+### END INIT INFO
|
|
|
|
REDISPORT=6379
|
|
-EXEC=/usr/local/bin/redis-server
|
|
+EXEC=/usr/sbin/redis-server
|
|
|
|
-PIDFILE=/var/run/redis_${REDISPORT}.pid
|
|
-CONF="/etc/redis/${REDISPORT}.conf"
|
|
+PIDFILE=/var/run/redis.pid
|
|
+CONF=/etc/redis.conf
|
|
+
|
|
+. /etc/rc.status
|
|
+
|
|
+rc_reset
|
|
|
|
case "$1" in
|
|
start)
|
|
if [ -f $PIDFILE ]
|
|
then
|
|
- echo -n "$PIDFILE exists, process is already running or crashed\n"
|
|
+ echo -n "$PIDFILE exists, process is already running or crashed"
|
|
+ rc_failed
|
|
else
|
|
- echo -n "Starting Redis server...\n"
|
|
- $EXEC $CONF
|
|
+ echo -n "Starting Redis server..."
|
|
+ $EXEC $CONF > /dev/null
|
|
+ rc_status -v
|
|
fi
|
|
;;
|
|
stop)
|
|
if [ ! -f $PIDFILE ]
|
|
then
|
|
- echo -n "$PIDFILE does not exist, process is not running\n"
|
|
+ echo -n "$PIDFILE does not exist, process is not running"
|
|
+ rc_failed
|
|
else
|
|
- echo -n "Stopping ...\n"
|
|
- echo -n "SHUTDOWN\r\n" | nc localhost $REDISPORT &
|
|
+ echo -n "Stopping Redis server ..."
|
|
+ echo -e "SHUTDOWN\r" | netcat localhost $REDISPORT &
|
|
PID=$(cat $PIDFILE)
|
|
while [ -x /proc/${PIDFILE} ]
|
|
do
|
|
- echo "Waiting for Redis to shutdown ..."
|
|
sleep 1
|
|
done
|
|
rm $PIDFILE
|
|
- echo "Redis stopped"
|
|
fi
|
|
+ rc_status -v
|
|
;;
|
|
+ status)
|
|
+ if [ ! -f $PIDFILE ]
|
|
+ then
|
|
+ echo -n "Redis is not running"
|
|
+ else
|
|
+ echo -n "Redis is running"
|
|
+ fi
|
|
+ rc_status -v
|
|
+ ;;
|
|
+ *)
|
|
+ echo "Usage: $0 [start|stop|status]"
|
|
+ ;;
|
|
esac
|
|
+
|
|
+rc_exit
|