]>
Commit | Line | Data |
---|---|---|
ca65ef86 | 1 | #!/bin/sh |
36bbbd00 ER |
2 | # |
3 | # gearmand Startup script for the Gearman server | |
4 | # | |
ca65ef86 ER |
5 | # chkconfig: 345 85 15 |
6 | # | |
36bbbd00 ER |
7 | # description: Gearman is a distributed job system. |
8 | # processname: gearmand | |
9 | # config: /etc/sysconfig/gearmand | |
10 | # pidfile: /var/run/gearmand/gearmand.pid | |
11 | # | |
36bbbd00 | 12 | |
ca65ef86 | 13 | # Source function library |
36bbbd00 ER |
14 | . /etc/rc.d/init.d/functions |
15 | ||
ca65ef86 ER |
16 | # Get network config |
17 | . /etc/sysconfig/network | |
18 | ||
19 | # Check that networking is up. | |
20 | if is_yes "${NETWORKING}"; then | |
21 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then | |
22 | msg_network_down "Gearmand job server" | |
23 | exit 1 | |
24 | fi | |
25 | else | |
26 | exit 0 | |
36bbbd00 ER |
27 | fi |
28 | ||
ca65ef86 ER |
29 | # Set defaults |
30 | OPTIONS="" | |
36bbbd00 | 31 | |
ca65ef86 ER |
32 | # Get service config - may override defaults |
33 | [ -f /etc/sysconfig/gearmand ] && . /etc/sysconfig/gearmand | |
36bbbd00 | 34 | |
4b3195b4 | 35 | pidfile="/var/run/gearmand/gearmand.pid" |
ca65ef86 ER |
36 | lockfile="/var/lock/subsys/gearmand" |
37 | gearmand="/usr/sbin/gearmand" | |
38 | procname="gearmand" | |
36bbbd00 ER |
39 | |
40 | start() { | |
ca65ef86 ER |
41 | # Check if the service is already running? |
42 | if [ -f $lockfile ]; then | |
43 | msg_already_running "Gearmand job server" | |
44 | return | |
45 | fi | |
46 | ||
47 | msg_starting "Gearmand job server" | |
4830b523 | 48 | daemon --pidfile $pidfile $gearmand -d --user=gearmand --pid-file=$pidfile $OPTIONS |
ca65ef86 ER |
49 | RETVAL=$? |
50 | [ $RETVAL -eq 0 ] && touch $lockfile | |
36bbbd00 ER |
51 | } |
52 | ||
53 | stop() { | |
ca65ef86 ER |
54 | if [ ! -f $lockfile ]; then |
55 | msg_not_running "Gearmand job server" | |
56 | return | |
57 | fi | |
58 | ||
59 | # Stop daemons. | |
60 | msg_stopping "Gearmand job server" | |
61 | killproc --pidfile $pidfile $procname -TERM | |
62 | rm -f $lockfile | |
63 | } | |
64 | ||
65 | condrestart() { | |
66 | if [ ! -f $lockfile ]; then | |
67 | msg_not_running "Gearmand job server" | |
68 | RETVAL=$1 | |
69 | return | |
70 | fi | |
71 | ||
72 | stop | |
73 | start | |
36bbbd00 ER |
74 | } |
75 | ||
ca65ef86 | 76 | RETVAL=0 |
36bbbd00 ER |
77 | # See how we were called. |
78 | case "$1" in | |
79 | start) | |
80 | start | |
81 | ;; | |
82 | stop) | |
83 | stop | |
84 | ;; | |
ca65ef86 | 85 | restart) |
36bbbd00 ER |
86 | stop |
87 | start | |
88 | ;; | |
ca65ef86 ER |
89 | try-restart) |
90 | condrestart 0 | |
91 | ;; | |
92 | force-reload) | |
93 | condrestart 7 | |
94 | ;; | |
95 | status) | |
96 | status --pidfile $pidfile $procname | |
97 | RETVAL=$? | |
36bbbd00 ER |
98 | ;; |
99 | *) | |
ca65ef86 ER |
100 | msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" |
101 | exit 3 | |
36bbbd00 ER |
102 | esac |
103 | ||
104 | exit $RETVAL |