I just wanted to share a little batch script I wrote to test if GeoServer is running. This checks port 8080 once a second to see if it's listening, and if it is, an environment flag is set and then exits.
Script #1 waits forever, but #2 times out after a minute.
There are probably slicker ways of doing this, but I was pretty happy to figure this out. I hope someone else may find them useful.
Script #1
---------
@echo off
cls
set gs="" >nul 2>nul
echo Waiting for GeoServer to start...
:try
netstat -an | findstr /RC:":8080 .*LISTENING" >NUL && set gs=start
ping 127.0.0.1 -n 2 -w 1000 > nul
if %gs%==start goto end else goto try
goto try
:end
set gs="" >nul 2>nul
echo GeoServer started!
Script #2
---------
@echo off
cls
set gs=0 >nul 2>nul
echo Waiting for GeoServer to start...
:try
if %gs%==60 goto fail
set /a gs+=1
netstat -an | findstr /RC:":8080 .*LISTENING" >NUL && set gs=start
ping 127.0.0.1 -n 2 -w 1000 > nul
if %gs%==start goto success else goto try
goto try
:success
set gs="" >nul 2>nul
echo GeoServer started!
goto end
:fail
set gs="" >nul 2>nul
echo ERROR: GeoServer could not be started.
:end
Thanks,
Mike Pumphrey
OpenGeo - http://opengeo.org