Search code examples
c#rabbitmqerlangwindows-server-2012-r2

How can I know whether RabbitMQ application has started


I have a c# code that installs rabbitmq 3.7.4, erlang 20.2 on windows server 2012 R2 and I need to know when the application (not the service) has started. After running rabbitmq-service install and rabbitmq-service start I'm looking for a command line that will indicate that the application is running. I'm aware of the wait pid_file, wait --pid pid command but can't locate the pid file on my machine. The documantaion says:

This command will wait for the RabbitMQ application to start at the node. It will wait for the pid file to be created if pidfile is specified

specified where?

rabbitmq-echopid.bat returns:

The system cannot find the path specified.


Solution

  • On Windows, RabbitMQ does not create a PID file by default, so you have to discover the PID and then pass it as an argument: rabbitmqctl.bat wait -P PID

    To discover the PID, you can run the following using the name of your RabbitMQ node:

    .\rabbitmq-echopid.bat rabbit@my-hostname
    

    At this time, there is a bug where The system cannot find... will be echoed before the PID is echoed. I filed this bug and will have a fix in soon, but in the meantime you can edit the rabbitmq-echopid.bat script to change !TDP0! to %TDP0%.

    You can also use any other Windows tool to find the PID of the erl.exe process running RabbitMQ - see the script for an example of wmic.exe, or you could use tasklist, or Powershell, etc.