forked from choria-legacy/marionette-collective
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmcollective.init-rh
executable file
·126 lines (114 loc) · 2.69 KB
/
mcollective.init-rh
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/sh
#
# mcollective Application Server for STOMP based agents
#
# chkconfig: 345 24 76
#
# description: mcollective lets you build powerful Stomp compatible middleware clients in ruby without having to worry too
# much about all the setup and management of a Stomp connection, it also provides stats, logging and so forth
# as a bonus.
#
### BEGIN INIT INFO
# Provides: mcollective
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
mcollectived="/usr/sbin/mcollectived"
pidfile="/var/run/mcollectived.pid"
if [ -d /var/lock/subsys ]; then
# RedHat/CentOS/etc who use subsys
lockfile="/var/lock/subsys/mcollective"
else
# The rest of them
lockfile="/var/lock/mcollective"
fi
# Check that binary exists
if ! [ -f $mcollectived ]; then
echo "mcollectived binary not found"
exit 0
fi
# Source function library.
. /etc/init.d/functions
# Determine if we can use the -p option to daemon, killproc, and status.
# RHEL < 5 can't.
if status | grep -q -- '-p' 2>/dev/null; then
daemonopts="--pidfile $pidfile"
pidopts="-p $pidfile"
fi
start() {
echo -n "Starting mcollective: "
daemon ${daemonopts} ${mcollectived} \
--pid=${pidfile} --config="/etc/mcollective/server.cfg"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n "Shutting down mcollective: "
killproc ${pidopts} -d 10 ${mcollectived}
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
return $RETVAL
}
restart() {
stop
start
}
reload_agents() {
echo -n "Reloading mcollective agents: "
killproc ${pidopts} ${mcollectived} -USR1
RETVAL=$?
echo
return $RETVAL
}
reload_loglevel() {
echo -n "Cycling mcollective logging level: "
killproc ${pidopts} ${mcollectived} -USR2
RETVAL=$?
echo
return $RETVAL
}
rh_status() {
status ${pidopts} ${mcollectived}
RETVAL=$?
return $RETVAL
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
condrestart)
rh_status_q || exit 0
restart
;;
reload-agents)
reload_agents
;;
reload-loglevel)
reload_loglevel
;;
status)
rh_status
;;
*)
echo "Usage: mcollectived {start|stop|restart|condrestart|reload-agents|reload-loglevel|status}"
RETVAL=2
;;
esac
exit $RETVAL