git: f39b219f5749 - main - net/rabbitmq: rc.d improvements

From: Jimmy Olgeni <olgeni_at_FreeBSD.org>
Date: Sat, 18 Feb 2023 08:11:45 UTC
The branch main has been updated by olgeni:

URL: https://cgit.FreeBSD.org/ports/commit/?id=f39b219f5749d7b2dc3f46bfda9de37e9b5f1625

commit f39b219f5749d7b2dc3f46bfda9de37e9b5f1625
Author:     Jimmy Olgeni <olgeni@FreeBSD.org>
AuthorDate: 2023-02-17 19:40:18 +0000
Commit:     Jimmy Olgeni <olgeni@FreeBSD.org>
CommitDate: 2023-02-18 08:10:45 +0000

    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>
---
 net/rabbitmq/files/rabbitmq.in | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/rabbitmq/files/rabbitmq.in b/net/rabbitmq/files/rabbitmq.in
index 0e0024484e8e..b2581043633d 100644
--- a/net/rabbitmq/files/rabbitmq.in
+++ b/net/rabbitmq/files/rabbitmq.in
@@ -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