[chef] Re: pid file for rabbitmq and couchdb


Chronological Thread 
  • From: Tom H < >
  • To:
  • Subject: [chef] Re: pid file for rabbitmq and couchdb
  • Date: Wed, 25 Jan 2012 20:20:52 +0000

On 25/01/12 19:25, Tom H wrote:
" type="cite">
Ohai Shefs,

The rabbitmq docs indicate that rabbit would create a pid file as controlled by the RABBITMQ_PID_FILE environment variable, however on inspection there is no reason that the init.d/rabbitmq-server script does that... Presumably something to do with how the service is started in rabbit-multi mode...?

Any suggestion on how to get rabbit or couchdb to use a pid file, so they can be monitored by monit?

For rabbit, it looks like the /etc/rc.d/init.d/rabbitmq-server  elects not to create a pid file because the script is using the command for clustered rabbitmq ie rabbitmq-multi and could potentially have a bunch of pids to write out.

As the NODE_COUNT is hard coded to 1, its possible to put in some commands to force a pid file if you need it. Attached is a diff file adding a couple of lines to the init script shipped with CentOS 5.7 epel package to add a pid file at the default location.

Regards,
Tom







--- /var/cache/systemstate/etc/rc.d/init.d/rabbitmq-server    2011-01-15 15:54:04.000000000 -0800
+++ /etc/rc.d/init.d/rabbitmq-server    2012-01-25 12:08:44.000000000 -0800
@@ -35,6 +34,8 @@
     . $DEFAULTS_FILE
 fi
 
+pidfile=${PID_FILE-/var/run/rabbitmq/pid}
+
 RETVAL=0
 set -e
 
@@ -45,6 +46,8 @@
       0)
         echo SUCCESS
         [ -n "$LOCK_FILE" ] && touch $LOCK_FILE
+        #hmm, bit of a hack really.
+        $DAEMON status | grep Pid | egrep -o "Pid .*:" | egrep -o "[0-9]+" > $pidfile
         RETVAL=0
         ;;
       1)
@@ -67,11 +70,13 @@
         RETVAL=$?
         if [ $RETVAL = 0 ] ; then
             [ -n "$LOCK_FILE" ] && rm -rf $LOCK_FILE
+            ##hack for monit
+            [ -n "$pidfile" ] && rm -f $pidfile
         else
             echo FAILED - check ${INIT_LOG_DIR}/shutdown_log, _err
         fi
     else
-        echo No nodes running
+        echo No nodes running
         RETVAL=0
     fi
     set -e




Archive powered by MHonArc 2.6.16.

§