2
0

redis_init_script.tpl 1023 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. case "$1" in
  2. start)
  3. if [ -f $PIDFILE ]
  4. then
  5. echo "$PIDFILE exists, process is already running or crashed"
  6. else
  7. echo "Starting Redis server..."
  8. $EXEC $CONF
  9. fi
  10. ;;
  11. stop)
  12. if [ ! -f $PIDFILE ]
  13. then
  14. echo "$PIDFILE does not exist, process is not running"
  15. else
  16. PID=$(cat $PIDFILE)
  17. echo "Stopping ..."
  18. $CLIEXEC -p $REDISPORT shutdown
  19. while [ -x /proc/${PID} ]
  20. do
  21. echo "Waiting for Redis to shutdown ..."
  22. sleep 1
  23. done
  24. echo "Redis stopped"
  25. fi
  26. ;;
  27. status)
  28. if [ ! -f $PIDFILE ]
  29. then
  30. echo 'Redis is not running'
  31. else
  32. echo "Redis is running ($(<$PIDFILE))"
  33. fi
  34. ;;
  35. restart)
  36. $0 stop
  37. $0 start
  38. ;;
  39. *)
  40. echo "Please use start, stop, restart or status as first argument"
  41. ;;
  42. esac