net/rabbitmq: rc.d improvements

This commit creates a separate directory at /var/run/rabbitmq to
host the RabbitMQ pid file. Previously, the pid file was not being
created properly (it was empty) and this was causing issues with
the process of waiting for pids (as the pid file existed, but had
no value and was considered "garbage"). With this change the pid
file is created with the correct value, enabling the process of
waiting for pids to complete successfully; now the startup script
returns exit code 0.

Additionally, this commit exports the variables RABBITMQ_HOME,
RABBITMQ_LOG_BASE, and RABBITMQ_PID_FILE so that the RabbitMQ process
can properly locate the pid file.

These changes resolve PR 264062.

PR:		264062
Reported by:	FiLiS <freebsdbugs@filis.org>
This commit is contained in:
Jimmy Olgeni 2023-02-17 20:40:18 +01:00
parent 232979e414
commit f39b219f57

View file

@ -23,7 +23,7 @@ load_rc_config $name
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"
pidfile="/var/run/rabbitmq/${name}.pid"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
@ -64,7 +64,11 @@ rabbitmq_start()
chmod 600 ${RABBITMQ_HOME}/.erlang.cookie
fi
install -o ${rabbitmq_user} /dev/null ${pidfile}
install -d -o ${rabbitmq_user} -g ${rabbitmq_user} /var/run/${name}
export RABBITMQ_HOME RABBITMQ_LOG_BASE RABBITMQ_PID_FILE
rm -f ${pidfile}
debug "Running: rabbitmq-server -detached"
su -m ${rabbitmq_user} -c "${rabbitmq_server} -detached" >/dev/null 2>&1
@ -75,6 +79,7 @@ rabbitmq_start()
rabbitmq_stop()
{
echo "Stopping ${name}."
if [ -f ${pidfile} ]; then
debug "Running: ${rabbitmq_ctl} stop ${pidfile}"
su -m ${rabbitmq_user} -c "${rabbitmq_ctl} stop ${pidfile}" >/dev/null 2>&1