redis-server2 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: redis-server
  4. # Required-Start: $syslog $remote_fs
  5. # Required-Stop: $syslog $remote_fs
  6. # Should-Start: $local_fs
  7. # Should-Stop: $local_fs
  8. # Default-Start: 2 3 4 5
  9. # Default-Stop: 0 1 6
  10. # Short-Description: redis-server - Persistent key-value db
  11. # Description: redis-server - Persistent key-value db
  12. ### END INIT INFO
  13. NAME=`basename ${0}`
  14. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  15. DAEMON=/usr/bin/redis-server
  16. DAEMON_ARGS=/etc/redis/${NAME}.conf
  17. DESC=${name}
  18. RUNDIR=/var/run/redis
  19. PIDFILE=$RUNDIR/${name}.pid
  20. test -x $DAEMON || exit 0
  21. set -e
  22. case "$1" in
  23. start)
  24. echo -n "Starting $DESC: "
  25. mkdir -p $RUNDIR
  26. touch $PIDFILE
  27. chown redis:redis $RUNDIR $PIDFILE
  28. chmod 755 $RUNDIR
  29. if start-stop-daemon --start --quiet --umask 007 --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON -- $DAEMON_ARGS
  30. then
  31. echo "$NAME."
  32. else
  33. echo "failed"
  34. fi
  35. ;;
  36. stop)
  37. echo -n "Stopping $DESC: "
  38. if start-stop-daemon --stop --retry forever/QUIT/1 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
  39. then
  40. echo "$NAME."
  41. else
  42. echo "failed"
  43. fi
  44. rm -f $PIDFILE
  45. ;;
  46. restart|force-reload)
  47. ${0} stop
  48. ${0} start
  49. ;;
  50. status)
  51. echo -n "$DESC is "
  52. if start-stop-daemon --stop --quiet --signal 0 --name ${NAME} --pidfile ${PIDFILE}
  53. then
  54. echo "running"
  55. else
  56. echo "not running"
  57. exit 1
  58. fi
  59. ;;
  60. *)
  61. echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
  62. exit 1
  63. ;;
  64. esac
  65. exit 0