forked from brianlmoon/GearmanManager
/
rhel.sh
80 lines (71 loc) · 1.64 KB
/
rhel.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# Gearman worker manager
### BEGIN INIT INFO
# Provides: gearman-manager
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable gearman manager daemon
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
DAEMON=/usr/local/bin/gearman-manager
PIDDIR=/var/run/gearman
PIDFILE=${PIDDIR}/manager.pid
LOGFILE=/var/log/gearman-manager.log
CONFIGDIR=/etc/gearman-manager
GEARMANUSER="gearmand"
PARAMS="-c ${CONFIGDIR}/config.ini"
RETVAL=0
start() {
echo -n $"Starting gearman-manager: "
if ! test -d ${PIDDIR}
then
mkdir ${PIDDIR}
chown ${GEARMANUSER} ${PIDDIR}
fi
daemon --pidfile=$PIDFILE $DAEMON \
-P $PIDFILE \
-l $LOGFILE \
-u $GEARMANUSER \
-d \
$PARAMS
RETVAL=$?
echo
return $RETVAL
}
stop() {
echo -n $"Stopping gearman-manager: "
killproc -p $PIDFILE $DAEMON
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p $PIDFILE $DAEMON
RETVAL=$?
;;
restart|reload)
stop
start
;;
condrestart|try-restart)
if status -p $PIDFILE $DAEMON >&/dev/null; then
stop
start
fi
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|condrestart|status|help}"
RETVAL=3
esac
exit $RETVAL