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
21# Source function library.
22. /etc/rc.d/init.d/functions
23
24if [ -f /etc/sysconfig/gearmand ]; then
25        . /etc/sysconfig/gearmand
26fi
27
28[ -z "${PIDFILE}" ] && pidfile="/var/run/gearmand/gearmand.pid"
29[ -z "${LOCKFILE}" ] && lockfile="/var/lock/subsys/gearmand"
30
31gearmand=/usr/sbin/gearmand
32prog=gearmand
33
34RETVAL=0
35
36start() {
37        echo -n $"Starting $prog: "
38        daemon --pidfile=$pidfile --user=gearmand $gearmand -d $OPTIONS
39        RETVAL=$?
40        echo
41        [ $RETVAL = 0 ] && (touch $lockfile; pgrep -f $gearmand > $pidfile)
42        return $RETVAL
43}
44
45stop() {
46	echo -n $"Stopping $prog: "
47	killproc -p $pidfile $gearmand
48	RETVAL=$?
49	echo
50	[ $RETVAL = 0 ] && rm -f $lockfile $pidfile
51}
52
53# See how we were called.
54case "$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	stop
67	start
68	;;
69  condrestart|try-restart)
70	if status -p $pidfile $gearmand >&/dev/null; then
71		stop
72		start
73	fi
74	;;
75  *)
76	echo $"Usage: $prog {start|stop|restart|reload|condrestart|status|help}"
77	RETVAL=3
78esac
79
80exit $RETVAL
81
82