summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Apperly <jim@rabbitmq.com>2012-02-15 15:00:19 +0000
committerJim Apperly <jim@rabbitmq.com>2012-02-15 15:00:19 +0000
commit0e5ab33d56c203527804329258828e3d940dd977 (patch)
treeb69267dc39e648f9f27305c86484a624ac054487
parent4e36f45370d47b2827d81fdca4fbf9776024132c (diff)
downloadrabbitmq-server-0e5ab33d56c203527804329258828e3d940dd977.tar.gz
Add errorlevels and wait-looping to rabbitmq-echopid.bat
-rw-r--r--scripts/rabbitmq-echopid.bat42
1 files changed, 27 insertions, 15 deletions
diff --git a/scripts/rabbitmq-echopid.bat b/scripts/rabbitmq-echopid.bat
index 2efbab7a..c1982400 100644
--- a/scripts/rabbitmq-echopid.bat
+++ b/scripts/rabbitmq-echopid.bat
@@ -1,40 +1,52 @@
@echo off
+REM Usage: rabbitmq-echopid.bat <rabbitmq_nodename> [<wait>]
+REM
+REM <rabbitmq_nodename> sname of the erlang node to connect to (required)
+REM <wait> if specified, causes the script to wait until a pid is detected
+
setlocal
-:: get the name of the node ::
-set NODENAME="%RABBITMQ_NODENAME%"
-if "%NODENAME%"=="" (
- set NODENAME=rabbit@%COMPUTERNAME%
-)
+if "%1"=="" goto wmic_fail
+if "%2"=="wait" set WAIT=%2
+
+:: set the node name ::
+set NODENAME="%1"
:: check that wmic exists ::
set WMIC_PATH=%SYSTEMROOT%\System32\Wbem\wmic.exe
if not exist "%WMIC_PATH%" (
- REM echo "%WMIC_PATH%" not found.
- goto :wmic_end
+ goto wmic_fail
)
:: build node name expression ::
-set RABBITMQ_NODENAME_CLI=-sname %RABBITMQ_NODENAME%
+set RABBITMQ_NODENAME_CLI=-sname %1
-FOR /F "usebackq tokens=* skip=1" %%P IN (`%%WMIC_PATH%% process where "name='erl.exe' and commandline like '%%%RABBITMQ_NODENAME_CLI%%%'" get processid 2^>nul`) do (
- SET PID=%%P
- goto :wmic_echopid
+:wmic_getpid
+for /F "usebackq tokens=* skip=1" %%P IN (`%%WMIC_PATH%% process where "name='erl.exe' and commandline like '%%%RABBITMQ_NODENAME_CLI%%%'" get processid 2^>nul`) do (
+ set PID=%%P
+ goto wmic_echopid
)
:wmic_echopid
-
:: check for pid not found ::
if "%PID%" == "" (
- REM echo Could not find erl.exe pid
- goto :wmic_end
+ if not defined WAIT goto wmic_fail
+ PING 127.0.0.1 -n 2 > nul
+ goto wmic_getpid
)
:: show pid ::
echo %PID%
:: all done ::
-:wmic_end
+:wmic_ok
+endlocal
+EXIT /B 0
+:: something went wrong ::
+:wmic_fail
endlocal
+EXIT /B 1
+
+