blob: 3aafcb1d9fb95afecaff8cb54c1a2d90184a4e47 (
plain)
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
|
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: rabbitmq
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable RabbitMQ
#
# rabbitmq_enable="YES"
. /etc/rc.subr
name=rabbitmq
rcvar=rabbitmq_enable
load_rc_config $name
# Set some defaults
: ${rabbitmq_enable="NO"}
: ${rabbitmq_user="rabbitmq"}
rabbitmq_server="%%PREFIX%%/sbin/rabbitmq-server"
rabbitmq_ctl="%%PREFIX%%/sbin/rabbitmqctl"
rabbitmq_env_conf="%%PREFIX%%/etc/rabbitmq/rabbitmq-env.conf"
pidfile="/var/run/${name}.pid"
daemon_pidfile="/var/run/${name}-daemon.pid"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
rotate_logs_cmd="su -m ${rabbitmq_user} -c 'sh -c \"${rabbitmq_ctl} rotate_logs\"'"
status_cmd="su -m ${rabbitmq_user} -c 'sh -c \"${rabbitmq_ctl} status\"'"
extra_commands="rotate_logs status"
: ${RABBITMQ_LOG_BASE:=/var/log/${name}}
if [ -f ${rabbitmq_env_conf} ]; then
. ${rabbitmq_env_conf}
fi
export RABBITMQ_HOME=/var/db/${name}
# Prevent conflicts with amqp_client and rabbit_common applications that
# may be installed in ERL_LIBS.
unset ERL_LIBS
rabbitmq_start()
{
echo "Starting ${name}."
if [ -d ${RABBITMQ_HOME} ]; then
chown -R ${rabbitmq_user}:${rabbitmq_user} ${RABBITMQ_HOME}
fi
mkdir -p ${RABBITMQ_LOG_BASE}
chown -R ${rabbitmq_user}:${rabbitmq_user} ${RABBITMQ_LOG_BASE}
if [ -f ${RABBITMQ_HOME}/.erlang.cookie ]; then
chmod 600 ${RABBITMQ_HOME}/.erlang.cookie
fi
env HOME=${RABBITMQ_HOME} /usr/sbin/daemon -c -f -u ${rabbitmq_user} -p ${pidfile} -P ${daemon_pidfile} ${rabbitmq_server}
debug "Running: rabbitmqctl wait ${pidfile}"
${rabbitmq_ctl} wait ${pidfile} >/dev/null 2>&1
}
rabbitmq_stop()
{
echo "Stopping ${name}."
if [ -f ${daemon_pidfile} ]; then
read daemon_pid < ${daemon_pidfile}
debug "Running: ${rabbitmq_ctl} stop ${pidfile}"
su -m ${rabbitmq_user} -c "sh -c \"${rabbitmq_ctl} stop ${pidfile}\"" >/dev/null 2>&1
[ -n "${daemon_pid}" ] && wait_for_pids ${daemon_pid}
else
debug "Running: ${rabbitmq_ctl} stop"
su -m ${rabbitmq_user} -c "sh -c \"${rabbitmq_ctl} stop\"" >/dev/null 2>&1
fi
}
run_rc_command "$1"
|