2
0

redis_init_script.tpl 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. PID=$(cat $PIDFILE)
  29. if [ ! -x /proc/${PID} ]
  30. then
  31. echo 'Redis is not running'
  32. else
  33. echo "Redis is running ($PID)"
  34. fi
  35. ;;
  36. restart)
  37. $0 stop
  38. $0 start
  39. ;;
  40. *)
  41. echo "Please use start, stop, restart or status as first argument"
  42. ;;
  43. esac