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
127
128
129
130
131
132
133
134
135
136
137
|
#!/bin/sh
#
# Copyright (c) 2009, 2010 Radim Kolar. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# $FreeBSD$
# PROVIDE: imq
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable Open MQ:
#
# imq_enable="YES"
# # optional
# imq_data="/var/spool/imq"
# imq_vmargs="-Xms150m -Xss128k -XX:MaxGCPauseMillis=5000"
# imq_brokerlist="hostname1:7676,hostname2:7676"
# imq_memory="256m"
. /etc/rc.subr
name="imq"
rcvar=imq_enable
load_rc_config $name
imq_enable=${imq_enable:-"NO"}
imq_data=${imq_data:-"/var/spool/imq"}
imq_vmargs=${imq_vmargs:-"-Xms150m -Xss128k -Xbatch -XX:MaxGCPauseMillis=5000"}
imq_memory=${imq_memory:-"256m"}
pidfile=/var/run/imq.pid
start_cmd="${name}_start"
start_precmd="${name}_build_cmdline"
command=%%PREFIX%%/imq/bin/imqbrokerd
command_args="-bgnd -silent"
command_interpreter="/bin/sh"
sigstop=INT
CONF_FILE=%%PREFIX%%/etc/mq/imqbrokerd.conf
#Check if we have enabled AUTOSTART feature, which overrides rcvar=NO
if ! checkyesno ${rcvar}; then
if [ -f $CONF_FILE -a -r $CONF_FILE ]; then
autostart=`grep "^AUTOSTART=" $CONF_FILE | cut -c11-`
if checkyesno autostart; then
eval ${rcvar}=YES
fi
fi
fi
imq_start()
{
if [ -z "$rc_pid" ]; then
echo -n "Starting $name"
# do we have memory limit defined?
if [ -n "$imq_memory" ]; then
#add imq_memory to vmargs
echo "$imq_vmargs" | grep -q -- '-Xmx'
if [ ! $? -eq 0 ]; then
imq_vmargs="$imq_vmargs -Xmx${imq_memory}"
fi
fi
#run with imq_vmargs if defined
if [ -n "$imq_vmargs" ]; then
${command} ${command_args} -vmargs "$imq_vmargs" &
else
${command} ${command_args} &
fi
echo -n $! > $pidfile
echo "."
else
echo "imq is already running with pid=$rc_pid."
fi
}
imq_build_cmdline()
{
# add imq_flags
if [ -n "$imq_flags" ]; then
command_args="$command_args $imq_flags"
fi
#check if RESTART feature is enabled
if [ -f $CONF_FILE -a -r $CONF_FILE ]; then
autorestart=`grep "^RESTART=" $CONF_FILE | cut -c9-`
autoargs=`grep "^ARGS=" $CONF_FILE | cut -c6-`
if checkyesno autorestart; then
command_args="$command_args -autorestart"
fi
fi
#load aditional command line arguments from broker config file
if [ -n $autoargs ]; then
echo "$autoargs" | grep -q -- '-varhome'
if [ ! $? -eq 0 ]; then
command_args="$command_args -varhome $imq_data $autoargs"
else
command_args="$command_args $autoargs"
fi
fi
#add brokerlist if not yet defined
if [ -n "$imq_brokerlist" ]; then
echo "$command_args" | grep -q -- '-cluster '
if [ ! $? -eq 0 ]; then
command_args="$command_args -cluster $imq_brokerlist"
fi
fi
return 0
}
run_rc_command "$1"
|