svn commit: r404880 - in head/net/rabbitmq: . files

Jimmy Olgeni olgeni at FreeBSD.org
Wed Dec 30 22:44:38 UTC 2015


Author: olgeni
Date: Wed Dec 30 22:44:36 2015
New Revision: 404880
URL: https://svnweb.freebsd.org/changeset/ports/404880

Log:
  Avoid calling "rabbitmqctl status" in a loop to make sure that RabbitMQ is
  started.
  
  "rabbitmqctl wait" alone should suffice, and the loop seems to cause some
  kind of race condition that causes a segfault in the Erlang VM.
  
  RabbitMQ would start anyway, but users would get a segmentation fault
  message on the console.
  
  We also wait on daemon(8)'s pid to make sure that restarts are synchronized
  (i.e. daemon(8) is stopped before starting it again with the same pidfile).
  
  PR:		204147
  Submitted by:	elofu17 at hotmail.com

Modified:
  head/net/rabbitmq/Makefile
  head/net/rabbitmq/files/rabbitmq.in

Modified: head/net/rabbitmq/Makefile
==============================================================================
--- head/net/rabbitmq/Makefile	Wed Dec 30 22:05:04 2015	(r404879)
+++ head/net/rabbitmq/Makefile	Wed Dec 30 22:44:36 2015	(r404880)
@@ -3,6 +3,7 @@
 
 PORTNAME=	rabbitmq
 PORTVERSION=	3.5.7
+PORTREVISION=	1
 CATEGORIES=	net
 MASTER_SITES=	http://www.rabbitmq.com/releases/rabbitmq-server/v${PORTVERSION}/
 DISTNAME=	${PORTNAME}-server-${PORTVERSION}

Modified: head/net/rabbitmq/files/rabbitmq.in
==============================================================================
--- head/net/rabbitmq/files/rabbitmq.in	Wed Dec 30 22:05:04 2015	(r404879)
+++ head/net/rabbitmq/files/rabbitmq.in	Wed Dec 30 22:44:36 2015	(r404880)
@@ -25,6 +25,7 @@ load_rc_config $name
 rabbitmq_server="%%PREFIX%%/sbin/rabbitmq-server"
 rabbitmq_ctl="%%PREFIX%%/sbin/rabbitmqctl"
 pidfile="/var/run/${name}.pid"
+daemon_pidfile="/var/run/${name}-daemon.pid"
 
 start_cmd="${name}_start"
 stop_cmd="${name}_stop"
@@ -46,35 +47,18 @@ rabbitmq_start()
 		chown -R ${rabbitmq_user}:${rabbitmq_user} ${RABBITMQ_HOME}
 	fi
 
-	env HOME=${RABBITMQ_HOME} daemon -c -f -u ${rabbitmq_user} -p ${pidfile} ${rabbitmq_server}
-
-	local _attempt=10
-
-	while [ ${_attempt} -gt 0 ]; do
-		debug "Running: rabbitmqctl status (${_attempt})"
-		$rabbitmq_ctl status > /dev/null 2>&1 && break
-		_attempt=$((${_attempt} - 1))
-		sleep 1
-	done
-
-	if [ ${_attempt} -gt 0 ]; then
-		debug "Running: rabbitmqctl wait ${pidfile}"
-		$rabbitmq_ctl wait ${pidfile} >/dev/null 2>&1
-	fi
+	env HOME=${RABBITMQ_HOME} 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}."
-
-	debug "Running: ${rabbitmq_ctl} stop"
-
-	su -m ${rabbitmq_user} -c "sh -c \"${rabbitmq_ctl} stop\"" >/dev/null 2>&1
-
-	if [ -f ${pidfile} ]; then
-		read rc_pid < ${pidfile}
-		wait_for_pids $rc_pid
-	fi
+	[ -f ${daemon_pidfile} ] && 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}
 }
 
 run_rc_command "$1"


More information about the svn-ports-head mailing list