Memcached-init-Ubuntu 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #! /bin/bash
  2. ### BEGIN INIT INFO
  3. # Provides: memcached
  4. # Required-Start: $syslog
  5. # Required-Stop: $syslog
  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: memcached - Memory caching daemon
  11. # Description: memcached - Memory caching daemon
  12. ### END INIT INFO
  13. #
  14. # memcached: MemCached Daemon
  15. #
  16. # chkconfig: - 90 25
  17. # description: MemCached Daemon
  18. #
  19. PORT=11211
  20. USER=memcached
  21. MAXCONN=1024
  22. OPTIONS="-l 127.0.0.1"
  23. DAEMON=/usr/local/memcached/bin/memcached
  24. RETVAL=0
  25. prog="/usr/local/memcached/bin/memcached"
  26. start_instance() {
  27. echo -n $"Starting $prog ($1): "
  28. start-stop-daemon --start --quiet --pidfile /var/run/memcached/memcached.$1.pid --exec $DAEMON -- -d -p $PORT -u $USER -m $2 -c $MAXCONN -P /var/run/memcached/memcached.$1.pid $OPTIONS
  29. RETVAL=$?
  30. echo
  31. [ $RETVAL -eq 0 ] && touch /var/lock/memcached.$1
  32. let PORT="$PORT+1"
  33. }
  34. stop_instance() {
  35. echo -n $"Stopping $prog ($1): "
  36. start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/memcached/memcached.$1.pid --exec $DAEMON
  37. RETVAL=$?
  38. echo
  39. if [ $RETVAL -eq 0 ] ; then
  40. rm -f /var/lock/memcached.$1
  41. rm -f /var/run/memcached/memcached.$1.pid
  42. fi
  43. }
  44. start() {
  45. # insure that /var/run/memcached has proper permissions
  46. mkdir -p /var/run/memcached
  47. if [ "$(stat -c %U /var/run/memcached)" != "$USER" ]; then
  48. chown $USER /var/run/memcached
  49. fi
  50. start_instance default 256;
  51. #start_instance block 16;
  52. #start_instance content 128;
  53. #start_instance filter 128;
  54. #start_instance form 32;
  55. #start_instance menu 16;
  56. #start_instance page 8;
  57. #start_instance update 8;
  58. #start_instance views 8;
  59. }
  60. stop() {
  61. stop_instance default;
  62. #stop_instance block;
  63. #stop_instance content;
  64. #stop_instance filter;
  65. #stop_instance form;
  66. #stop_instance menu;
  67. #stop_instance page;
  68. #stop_instance update;
  69. #stop_instance views;
  70. }
  71. restart() {
  72. stop
  73. start
  74. }
  75. # See how we were called.
  76. case "$1" in
  77. start)
  78. start
  79. ;;
  80. stop)
  81. stop
  82. ;;
  83. status)
  84. status memcached
  85. ;;
  86. restart|reload|force-reload)
  87. restart
  88. ;;
  89. *)
  90. echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}"
  91. exit 1
  92. esac
  93. exit $?