[rabbitmq-discuss] /var/lib/rabbitmq/pids

297 views
Skip to first unread message

Ronen

unread,
Jul 5, 2011, 8:33:02 AM7/5/11
to rabbitmq...@lists.rabbitmq.com
Hey fellow rabbitmq users, Im setting up a rabbitmq server on Redhat
using version 2.5.0,

Id like to monitor the rabbitmq process using monit which requires a
pid file, looking trough web posts they mention the /var/lib/rabbitmq/
pids as the source for the pid file however this folder doesn't
exits.

Any idea how to provide a pid file for monit without the pids folder?

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

David Wragg

unread,
Jul 5, 2011, 8:44:06 AM7/5/11
to Ronen, rabbitmq...@lists.rabbitmq.com
Ronen <nar...@gmail.com> writes:
> Hey fellow rabbitmq users, Im setting up a rabbitmq server on Redhat
> using version 2.5.0,
>
> Id like to monitor the rabbitmq process using monit which requires a
> pid file, looking trough web posts they mention the /var/lib/rabbitmq/
> pids as the source for the pid file however this folder doesn't
> exits.
>
> Any idea how to provide a pid file for monit without the pids folder?

Do something like:

setsid sh -c 'echo $$ >$PIDFILE ; exec rabbitmq-server </dev/null >$RABBITMQ_LOG_BASE/rabbitmq_startup_log 2>&1' &
rabbitmqctl wait >/dev/null 2>&1

David

--
David Wragg
Staff Engineer, RabbitMQ
VMware, Inc.

Matthew Sackman

unread,
Jul 5, 2011, 8:44:55 AM7/5/11
to rabbitmq...@lists.rabbitmq.com
On Tue, Jul 05, 2011 at 05:33:02AM -0700, Ronen wrote:
> Any idea how to provide a pid file for monit without the pids folder?

$ rabbitmqctl status
Status of node rabbit@hazel ...
[{pid,30451},
...]

Yes, that will require some parsing to safely get that out (the order of
items in that list could potentially change), but a regex of
/{pid,\s*(\d+)/ (or some such) should be sufficient.

Matthew

Ronen

unread,
Jul 5, 2011, 9:22:53 AM7/5/11
to rabbitmq...@lists.rabbitmq.com
David did you mean to use:

"setsid sh -c 'echo $$ >$PIDFILE ; exec rabbitmq-server </dev/null >
$RABBITMQ_LOG_BASE/rabbitmq_startup_log 2>&1' &
rabbitmqctl wait >/dev/null 2>&1"

As the monit command entry or to use it within the init file itself?

Matthew, I did see the pid entry under the status, I was hopping to
skip the need of parsing it but I guess ill have to try it also

Thanks
Ronen

On Jul 5, 3:44 pm, Matthew Sackman <matt...@rabbitmq.com> wrote:
> On Tue, Jul 05, 2011 at 05:33:02AM -0700, Ronen wrote:
> > Any idea how to provide a pid file for monit without the pids folder?
>
> $ rabbitmqctl status
> Status of node rabbit@hazel ...
> [{pid,30451},
>  ...]
>
> Yes, that will require some parsing to safely get that out (the order of
> items in that list could potentially change), but a regex of
> /{pid,\s*(\d+)/ (or some such) should be sufficient.
>
> Matthew
> _______________________________________________
> rabbitmq-discuss mailing list

> rabbitmq-disc...@lists.rabbitmq.comhttps://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

Matthew Sackman

unread,
Jul 5, 2011, 9:28:20 AM7/5/11
to rabbitmq...@lists.rabbitmq.com
On Tue, Jul 05, 2011 at 06:22:53AM -0700, Ronen wrote:
> Matthew, I did see the pid entry under the status, I was hopping to
> skip the need of parsing it but I guess ill have to try it also

I think either approach would work ok, though both have drawbacks.

Editing the init file is a drawback from a maintanence pov, though the
solution there is more robust.

Using rabbitmqctl means you'll have a potential race - you'll think
you've started rabbit, but it can be a while before rabbitmqctl status
thinks rabbit's managed to start up. You could use rabbitmqctl wait in
this case, but that adds further complexity, and is buggy anyway!

Matthew
_______________________________________________
rabbitmq-discuss mailing list

rabbitmq...@lists.rabbitmq.com
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

David Wragg

unread,
Jul 5, 2011, 9:46:42 AM7/5/11
to Ronen, rabbitmq...@lists.rabbitmq.com
Ronen <nar...@gmail.com> writes:
> David did you mean to use:
>
> "setsid sh -c 'echo $$ >$PIDFILE ; exec rabbitmq-server </dev/null >
> $RABBITMQ_LOG_BASE/rabbitmq_startup_log 2>&1' &
> rabbitmqctl wait >/dev/null 2>&1"
>
> As the monit command entry or to use it within the init file itself?

You'll need to incorporate that into a script that monit runs. It
should be easy to incorporate into the rabbitmq-server init script,
which already contains commands very like those.

--
David Wragg
Staff Engineer, RabbitMQ
VMware, Inc.

Ronen

unread,
Jul 5, 2011, 10:51:40 AM7/5/11
to rabbitmq...@lists.rabbitmq.com
Ok this is how iv solved this, iv patched the rabbitmq-server init
file and added the following:

The following are added to the start function:

pid=`/usr/sbin/rabbitmqctl status | perl -n -e'/{pid,(\d+)/ && print
$1'`
echo $pid > /var/run/rabbitmq.pid

Right before:

echo SUCCESS

The pid file is deleted within the stop function:

rm /var/run/rabbitmq.pid

right after,

if [ $RETVAL = 0 ] ; then

Thanks David and Matthew
Ronen


On Jul 5, 4:46 pm, David Wragg <da...@rabbitmq.com> wrote:


> Ronen <nark...@gmail.com> writes:
> > David did you mean to use:
>
> > "setsid sh -c 'echo $$ >$PIDFILE ; exec rabbitmq-server </dev/null >
> > $RABBITMQ_LOG_BASE/rabbitmq_startup_log 2>&1' &
> >     rabbitmqctl wait >/dev/null 2>&1"
>
> > As the monit command entry or to use it within the init file itself?
>
> You'll need to incorporate that into a script that monit runs.  It
> should be easy to incorporate into the rabbitmq-server init script,
> which already contains commands very like those.
>
> --
> David Wragg
> Staff Engineer, RabbitMQ
> VMware, Inc.
> _______________________________________________
> rabbitmq-discuss mailing list

> rabbitmq-disc...@lists.rabbitmq.comhttps://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

Reply all
Reply to author
Forward
0 new messages