[rabbitmq-discuss] init script

44 views
Skip to first unread message

Greg Swallow

unread,
Mar 28, 2011, 9:37:23 AM3/28/11
to rabbitmq...@lists.rabbitmq.com
Hi,

I have questions about the init script.  I'm working with the version here:


I modified it a bit.  See below.  Specifically, I am curious about what this "$CONTROL wait > /dev/null 2>&1" line is.  I tried running "rabbitmqctl wait" and got an error back out of rabbitmqctl.  Am I missing something in my install?

Thanks.

--- rabbitmq-server.init.orig   2011-03-28 09:29:10.000000000 -0400
+++ rabbitmq-server.init        2011-03-28 09:32:47.000000000 -0400
@@ -16,16 +16,17 @@
 # Short-Description: Enable AMQP service provided by RabbitMQ broker
 ### END INIT INFO
 
-PATH=/sbin:/usr/sbin:/bin:/usr/bin
+PREFIX_DIR=/opt/rabbitmq/rabbitmq-2.4.0
+PATH=${PREFIX_DIR}/sbin:/sbin:/sbin:/usr/sbin:/bin:/usr/bin
 NAME=rabbitmq-server
 DAEMON=/usr/sbin/${NAME}
 CONTROL=/usr/sbin/rabbitmqctl
 DESC=rabbitmq-server
-USER=rabbitmq
+RUNAS_USER=rabbitmq
 ROTATE_SUFFIX=
 INIT_LOG_DIR=/var/log/rabbitmq
-
-LOCK_FILE= # This is filled in when building packages
+HOME=/var/lib/rabbitmq
+LOCK_FILE=/var/lock/rabbitmq.pid
 
 test -x $DAEMON || exit 0
 
@@ -41,7 +42,6 @@
         set +e
         setsid sh -c "$DAEMON > ${INIT_LOG_DIR}/startup_log \
             2> ${INIT_LOG_DIR}/startup_err" &
-        $CONTROL wait >/dev/null 2>&1
         RETVAL=$?
         set -e
         case "$RETVAL" in
@@ -101,7 +101,7 @@
     set -e
 }
 
-restart_running_rabbitmq () {
+restart_running_rabbitmq() {
     status_rabbitmq quiet
     if [ $RETVAL = 0 ] ; then
         restart_rabbitmq
@@ -116,6 +116,15 @@
     start_rabbitmq
 }
 
+become_rabbitmq() {
+    if [ "$USER" != "$RUNAS_USER" ]; then
+       su $RUNAS_USER -c "$*"
+       exit 0;
+    fi
+}
+
+become_rabbitmq $0 $*
+
 case "$1" in
     start)
         echo -n "Starting $DESC: "



ExactTarget

Greg Swallow

System Administrator

Phone | 317 524-5250

Yahoo IM | gswallow01

Email  | gswa...@exacttarget.com

Matthew Sackman

unread,
Mar 28, 2011, 11:09:04 AM3/28/11
to rabbitmq...@lists.rabbitmq.com
Hi Greg,

On Mon, Mar 28, 2011 at 09:37:23AM -0400, Greg Swallow wrote:
> I have questions about the init script. I'm working with the version here:
> http://hg.rabbitmq.com/rabbitmq-server/file/rabbitmq_v2_4_0/packaging/common/rabbitmq-server.init
>
> I modified it a bit.

Why? Just curious - is there something you think we should be
incorporating into the init script ourselves?

> Specifically, I am curious about what this "$CONTROL wait > /dev/null 2>&1" line is. I tried running "rabbitmqctl wait" and got an error back out of rabbitmqctl. Am I missing something in my install?

see man rabbitmqctl:

This command will wait for the RabbitMQ application to
start at the node. As long as the Erlang node is up but
the RabbitMQ application is down it will wait
indefinitely. If the node itself goes down, or takes
more than five seconds to come up, it will fail.

It was introduced in the 2.4.0 release.

Matthew
_______________________________________________
rabbitmq-discuss mailing list
rabbitmq...@lists.rabbitmq.com
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

Reply all
Reply to author
Forward
0 new messages