gearmand.init.in 1.8 KB

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