83eb2c3700
literal name_enable wherever possible, and ${name}_enable when it's not, to prepare for the demise of set_rcvar(). In cases where I had to hand-edit unusual instances also modify formatting slightly to be more uniform (and in some cases, correct). This includes adding some $FreeBSD$ tags, and most importantly moving rcvar= to right after name= so it's clear that one is derived from the other.
48 lines
1.2 KiB
Bash
48 lines
1.2 KiB
Bash
#!/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"
|
|
pidfile="/var/run/rabbitmq.pid"
|
|
|
|
start_cmd="${name}_start"
|
|
stop_cmd="env HOME=/var/db/rabbitmq su -m ${rabbitmq_user} -c 'sh -c \"${rabbitmq_ctl} stop\"'"
|
|
stop_postcmd="wait_for_pids $rc_pid"
|
|
rotate_logs_cmd="env HOME=/var/db/rabbitmq su -m ${rabbitmq_user} -c 'sh -c \"${rabbitmq_ctl} rotate_logs\"'"
|
|
status_cmd="env HOME=/var/db/rabbitmq su -m ${rabbitmq_user} -c 'sh -c \"${rabbitmq_ctl} status\"'"
|
|
extra_commands="rotate_logs status"
|
|
|
|
rabbitmq_start()
|
|
{
|
|
HOME=/var/db/rabbitmq
|
|
su -m ${rabbitmq_user} \
|
|
-c "sh -c \"${rabbitmq_server} -detached\""
|
|
# Grab pid (it appears that parsing the output of
|
|
# status is the most reliable method)
|
|
su -m ${rabbitmq_user} \
|
|
-c "sh -c \"${rabbitmq_ctl} status\"" \
|
|
| sed -n 's/[^p]*pid,\([0-9]*\)[^0-9]*/\1/p' > ${pidfile}
|
|
}
|
|
|
|
run_rc_command "$1"
|