gearmand.init 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/bash
  2. #
  3. # gearmand Startup script for the Gearman server
  4. #
  5. # chkconfig: - 85 15
  6. # description: Gearman is a distributed job system.
  7. # processname: gearmand
  8. # config: /etc/sysconfig/gearmand
  9. # pidfile: /var/run/gearmand/gearmand.pid
  10. #
  11. ### BEGIN INIT INFO
  12. # Provides: gearmand
  13. # Required-Start: $local_fs $network
  14. # Required-Stop: $local_fs $network
  15. # Default-Start:
  16. # Default-Stop:
  17. # Short-Description: start and stop the Gearman server
  18. # Description: Gearman is a distributed job system.
  19. ### END INIT INFO
  20. # Source function library.
  21. . /etc/rc.d/init.d/functions
  22. if [ -f /etc/sysconfig/gearmand ]; then
  23. . /etc/sysconfig/gearmand
  24. fi
  25. [ -z "${PIDFILE}" ] && pidfile="/var/run/gearmand/gearmand.pid"
  26. [ -z "${LOCKFILE}" ] && lockfile="/var/lock/subsys/gearmand"
  27. gearmand=/usr/sbin/gearmand
  28. prog=gearmand
  29. RETVAL=0
  30. start() {
  31. echo -n $"Starting $prog: "
  32. daemon --pidfile=$pidfile --user=gearmand $gearmand -d $OPTIONS
  33. RETVAL=$?
  34. echo
  35. [ $RETVAL = 0 ] && (touch $lockfile; pgrep -f $gearmand > $pidfile)
  36. return $RETVAL
  37. }
  38. stop() {
  39. echo -n $"Stopping $prog: "
  40. killproc -p $pidfile $gearmand
  41. RETVAL=$?
  42. echo
  43. [ $RETVAL = 0 ] && rm -f $lockfile $pidfile
  44. }
  45. # See how we were called.
  46. case "$1" in
  47. start)
  48. start
  49. ;;
  50. stop)
  51. stop
  52. ;;
  53. status)
  54. status -p $pidfile $gearmand
  55. RETVAL=$?
  56. ;;
  57. restart|reload)
  58. stop
  59. start
  60. ;;
  61. condrestart|try-restart)
  62. if status -p $pidfile $gearmand >&/dev/null; then
  63. stop
  64. start
  65. fi
  66. ;;
  67. *)
  68. echo $"Usage: $prog {start|stop|restart|reload|condrestart|status|help}"
  69. RETVAL=3
  70. esac
  71. exit $RETVAL