Permalink
Browse files

Add a status section to the init script

  • Loading branch information...
pete0emerson committed Feb 22, 2012
1 parent 62c394e commit 49b280de1d7ed5186c0dd182cea9d89dbb66e543
Showing with 19 additions and 0 deletions.
  1. +19 −0 utils/redis_init_script
View
@@ -10,6 +10,15 @@ CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf"
+pidof_redis() {
+ if [ -e "$PIDFILE" ]; then
+ if pidof redis-server | tr ' ' '\n' | grep -w $(cat $PIDFILE); then
+ return 0
+ fi
+ fi
+ return 1
+}
+
case "$1" in
start)
if [ -f $PIDFILE ]
@@ -36,6 +45,16 @@ case "$1" in
echo "Redis stopped"
fi
;;
+ status)
+ PID=$(pidof_redis) || true
+ if [ -n "$PID" ]; then
+ echo "redis-server is running (pid $PID)."
+ exit 1
+ else
+ echo "redis-server is NOT running."
+ exit 1
+ fi
+ ;;
*)
echo "Please use start or stop as first argument"
;;

0 comments on commit 49b280d

Please sign in to comment.