ankur20us

redis_init_script

Mar 25th, 2014
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # Simple Redis init.d script conceived to work on Linux systems
  4. # as it does use of the /proc filesystem.
  5.  
  6. REDISPORT=7070
  7. EXEC=/usr/local/bin/redis-server
  8. CLIEXEC=/usr/local/bin/redis-cli
  9.  
  10. PIDFILE=/var/run/redis_${REDISPORT}.pid
  11. CONF="/etc/redis/${REDISPORT}.conf"
  12.  
  13. case "$1" in
  14. start)
  15. if [ -f $PIDFILE ]
  16. then
  17. echo "$PIDFILE exists, process is already running or crashed"
  18. else
  19. echo "Starting Redis server..."
  20. $EXEC $CONF
  21. fi
  22. ;;
  23. stop)
  24. if [ ! -f $PIDFILE ]
  25. then
  26. echo "$PIDFILE does not exist, process is not running"
  27. else
  28. PID=$(cat $PIDFILE)
  29. echo "Stopping ..."
  30. $CLIEXEC -p $REDISPORT shutdown
  31. while [ -x /proc/${PID} ]
  32. do
  33. echo "Waiting for Redis to shutdown ..."
  34. sleep 1
  35. done
  36. echo "Redis stopped"
  37. fi
  38. ;;
  39. *)
  40. echo "Please use start or stop as first argument"
  41. ;;
  42. esac
Advertisement
Add Comment
Please, Sign In to add comment