1
0

Redis-server-init-CentOS 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/bin/sh
  2. #
  3. # redis - this script starts and stops the redis-server daemon
  4. #
  5. # chkconfig: - 85 15
  6. # description: Redis is a persistent key-value database
  7. # processname: redis-server
  8. # config: /usr/local/redis/etc/redis.conf
  9. # config: /etc/sysconfig/redis
  10. # pidfile: /var/run/redis.pid
  11. # Source function library.
  12. . /etc/rc.d/init.d/functions
  13. # Source networking configuration.
  14. . /etc/sysconfig/network
  15. # Check that networking is up.
  16. [ "$NETWORKING" = "no" ] && exit 0
  17. redis="/usr/local/redis/bin/redis-server"
  18. prog=$(basename $redis)
  19. REDIS_CONF_FILE="/usr/local/redis/etc/redis.conf"
  20. [ -f /etc/sysconfig/redis ] && . /etc/sysconfig/redis
  21. lockfile=/var/lock/subsys/redis
  22. start() {
  23. [ -x $redis ] || exit 5
  24. [ -f $REDIS_CONF_FILE ] || exit 6
  25. echo -n $"Starting $prog: "
  26. daemon $redis $REDIS_CONF_FILE
  27. retval=$?
  28. echo
  29. [ $retval -eq 0 ] && touch $lockfile
  30. return $retval
  31. }
  32. stop() {
  33. echo -n $"Stopping $prog: "
  34. killproc $prog -QUIT
  35. retval=$?
  36. echo
  37. [ $retval -eq 0 ] && rm -f $lockfile
  38. return $retval
  39. }
  40. restart() {
  41. stop
  42. start
  43. }
  44. reload() {
  45. echo -n $"Reloading $prog: "
  46. killproc $redis -HUP
  47. RETVAL=$?
  48. echo
  49. }
  50. force_reload() {
  51. restart
  52. }
  53. rh_status() {
  54. status $prog
  55. }
  56. rh_status_q() {
  57. rh_status >/dev/null 2>&1
  58. }
  59. case "$1" in
  60. start)
  61. rh_status_q && exit 0
  62. $1
  63. ;;
  64. stop)
  65. rh_status_q || exit 0
  66. $1
  67. ;;
  68. restart|configtest)
  69. $1
  70. ;;
  71. reload)
  72. rh_status_q || exit 7
  73. $1
  74. ;;
  75. force-reload)
  76. force_reload
  77. ;;
  78. status)
  79. rh_status
  80. ;;
  81. condrestart|try-restart)
  82. rh_status_q || exit 0
  83. ;;
  84. *)
  85. echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
  86. exit 2
  87. esac