SOLR-9046: Fix solr.cmd that wrongly assumes Jetty will always listen on 0.0.0.0

This commit is contained in:
Uwe Schindler 2016-04-27 23:59:51 +02:00
parent 9ab76a1e41
commit 3e6de6059f
3 changed files with 54 additions and 59 deletions

View File

@ -156,6 +156,9 @@ Bug Fixes
* SOLR-9016: Fix SolrIdentifierValidator to not allow empty identifiers. (Shai Erera) * SOLR-9016: Fix SolrIdentifierValidator to not allow empty identifiers. (Shai Erera)
* SOLR-9046: Fix solr.cmd that wrongly assumes Jetty will always listen on 0.0.0.0.
(Bram Van Dam, Uwe Schindler)
Optimizations Optimizations
---------------------- ----------------------
* SOLR-8722: Don't force a full ZkStateReader refresh on every Overseer operation. * SOLR-8722: Don't force a full ZkStateReader refresh on every Overseer operation.

View File

@ -681,15 +681,12 @@ IF "%SCRIPT_CMD%"=="stop" (
set found_it=0 set found_it=0
for /f "usebackq" %%i in (`dir /b "%SOLR_TIP%\bin" ^| findstr /i "^solr-.*\.port$"`) do ( for /f "usebackq" %%i in (`dir /b "%SOLR_TIP%\bin" ^| findstr /i "^solr-.*\.port$"`) do (
set SOME_SOLR_PORT= set SOME_SOLR_PORT=
For /F "Delims=" %%J In ('type "%SOLR_TIP%\bin\%%i"') do set SOME_SOLR_PORT=%%~J For /F "delims=" %%J In ('type "%SOLR_TIP%\bin\%%i"') do set SOME_SOLR_PORT=%%~J
if NOT "!SOME_SOLR_PORT!"=="" ( if NOT "!SOME_SOLR_PORT!"=="" (
for /f "tokens=2,5" %%j in ('netstat -aon ^| find "TCP " ^| find ":!SOME_SOLR_PORT! "') do ( for /f "tokens=2,5" %%j in ('netstat -aon ^| find "TCP " ^| find ":0 " ^| find ":!SOME_SOLR_PORT! "') do (
@REM j is the ip:port and k is the pid @REM j is the ip:port and k is the pid
IF NOT "%%k"=="0" ( IF NOT "%%k"=="0" (
@REM split the ip:port var by colon to see if the ip is 0.0.0.0 IF "%%j"=="%SOLR_JETTY_HOST%:!SOME_SOLR_PORT!" (
for /f "delims=: tokens=1,2" %%x IN ("%%j") do (
@REM x is the ip
IF "%%x"=="0.0.0.0" (
set found_it=1 set found_it=1
@echo Stopping Solr process %%k running on port !SOME_SOLR_PORT! @echo Stopping Solr process %%k running on port !SOME_SOLR_PORT!
set /A STOP_PORT=!SOME_SOLR_PORT! - 1000 set /A STOP_PORT=!SOME_SOLR_PORT! - 1000
@ -697,10 +694,9 @@ IF "%SCRIPT_CMD%"=="stop" (
del "%SOLR_TIP%"\bin\solr-!SOME_SOLR_PORT!.port del "%SOLR_TIP%"\bin\solr-!SOME_SOLR_PORT!.port
timeout /T 5 timeout /T 5
REM Kill it if it is still running after the graceful shutdown REM Kill it if it is still running after the graceful shutdown
For /f "tokens=2,5" %%M in ('netstat -nao ^| find "TCP " ^| find ":!SOME_SOLR_PORT! "') do ( For /f "tokens=2,5" %%M in ('netstat -nao ^| find "TCP " ^| find ":0 " ^| find ":!SOME_SOLR_PORT! "') do (
IF "%%N"=="%%k" ( IF "%%N"=="%%k" (
for /f "delims=: tokens=1,2" %%a IN ("%%M") do ( IF "%%M"=="%SOLR_JETTY_HOST%:!SOME_SOLR_PORT!" (
IF "%%a"=="0.0.0.0" (
@echo Forcefully killing process %%N @echo Forcefully killing process %%N
taskkill /f /PID %%N taskkill /f /PID %%N
) )
@ -711,8 +707,6 @@ IF "%SCRIPT_CMD%"=="stop" (
) )
) )
) )
)
)
if "!found_it!"=="0" echo No Solr nodes found to stop. if "!found_it!"=="0" echo No Solr nodes found to stop.
) ELSE ( ) ELSE (
set "SCRIPT_ERROR=Must specify the port when trying to stop Solr, or use -all to stop all running nodes on this host." set "SCRIPT_ERROR=Must specify the port when trying to stop Solr, or use -all to stop all running nodes on this host."
@ -720,10 +714,9 @@ IF "%SCRIPT_CMD%"=="stop" (
) )
) ELSE ( ) ELSE (
set found_it=0 set found_it=0
For /f "tokens=2,5" %%M in ('netstat -nao ^| find "TCP " ^| find ":%SOLR_PORT% "') do ( For /f "tokens=2,5" %%M in ('netstat -nao ^| find "TCP " ^| find ":0 " ^| find ":%SOLR_PORT% "') do (
IF NOT "%%N"=="0" ( IF NOT "%%N"=="0" (
for /f "delims=: tokens=1,2" %%x IN ("%%M") do ( IF "%%M"=="%SOLR_JETTY_HOST%:%SOLR_PORT%" (
IF "%%x"=="0.0.0.0" (
set found_it=1 set found_it=1
@echo Stopping Solr process %%N running on port %SOLR_PORT% @echo Stopping Solr process %%N running on port %SOLR_PORT%
set /A STOP_PORT=%SOLR_PORT% - 1000 set /A STOP_PORT=%SOLR_PORT% - 1000
@ -731,10 +724,9 @@ IF "%SCRIPT_CMD%"=="stop" (
del "%SOLR_TIP%"\bin\solr-%SOLR_PORT%.port del "%SOLR_TIP%"\bin\solr-%SOLR_PORT%.port
timeout /T 5 timeout /T 5
REM Kill it if it is still running after the graceful shutdown REM Kill it if it is still running after the graceful shutdown
For /f "tokens=2,5" %%j in ('netstat -nao ^| find "TCP " ^| find ":%SOLR_PORT% "') do ( For /f "tokens=2,5" %%j in ('netstat -nao ^| find "TCP " ^| find ":0 " ^| find ":%SOLR_PORT% "') do (
IF "%%N"=="%%k" ( IF "%%N"=="%%k" (
for /f "delims=: tokens=1,2" %%a IN ("%%j") do ( IF "%%j"=="%SOLR_JETTY_HOST%:%SOLR_PORT%" (
IF "%%a"=="0.0.0.0" (
@echo Forcefully killing process %%N @echo Forcefully killing process %%N
taskkill /f /PID %%N taskkill /f /PID %%N
) )
@ -743,8 +735,6 @@ IF "%SCRIPT_CMD%"=="stop" (
) )
) )
) )
)
)
if "!found_it!"=="0" echo No Solr found running on port %SOLR_PORT% if "!found_it!"=="0" echo No Solr found running on port %SOLR_PORT%
) )
@ -758,17 +748,15 @@ IF "%STOP_PORT%"=="" set /A STOP_PORT=%SOLR_PORT% - 1000
IF "%SCRIPT_CMD%"=="start" ( IF "%SCRIPT_CMD%"=="start" (
REM see if Solr is already running using netstat REM see if Solr is already running using netstat
For /f "tokens=2,5" %%j in ('netstat -aon ^| find "TCP " ^| find ":%SOLR_PORT% "') do ( For /f "tokens=2,5" %%j in ('netstat -aon ^| find "TCP " ^| find ":0 " ^| find ":%SOLR_PORT% "') do (
IF NOT "%%k"=="0" ( IF NOT "%%k"=="0" (
for /f "delims=: tokens=1,2" %%x IN ("%%j") do ( IF "%%j"=="%SOLR_JETTY_HOST%:%SOLR_PORT%" (
IF "%%x"=="0.0.0.0" (
set "SCRIPT_ERROR=Process %%k is already listening on port %SOLR_PORT%. If this is Solr, please stop it first before starting (or use restart). If this is not Solr, then please choose a different port using -p PORT" set "SCRIPT_ERROR=Process %%k is already listening on port %SOLR_PORT%. If this is Solr, please stop it first before starting (or use restart). If this is not Solr, then please choose a different port using -p PORT"
goto err goto err
) )
) )
) )
) )
)
@REM determine if -server flag is supported by current JVM @REM determine if -server flag is supported by current JVM
"%JAVA%" -server -version > nul 2>&1 "%JAVA%" -server -version > nul 2>&1
@ -954,10 +942,9 @@ for /f "usebackq" %%i in (`dir /b "%SOLR_TIP%\bin" ^| findstr /i "^solr-.*\.port
set SOME_SOLR_PORT= set SOME_SOLR_PORT=
For /F "Delims=" %%J In ('type "%SOLR_TIP%\bin\%%i"') do set SOME_SOLR_PORT=%%~J For /F "Delims=" %%J In ('type "%SOLR_TIP%\bin\%%i"') do set SOME_SOLR_PORT=%%~J
if NOT "!SOME_SOLR_PORT!"=="" ( if NOT "!SOME_SOLR_PORT!"=="" (
for /f "tokens=2,5" %%j in ('netstat -aon ^| find "TCP " ^| find ":!SOME_SOLR_PORT! "') do ( for /f "tokens=2,5" %%j in ('netstat -aon ^| find "TCP " ^| find ":0 " ^| find ":!SOME_SOLR_PORT! "') do (
IF NOT "%%k"=="0" ( IF NOT "%%k"=="0" (
for /f "delims=: tokens=1,2" %%x IN ("%%j") do ( if "%%j"=="%SOLR_JETTY_HOST%:!SOME_SOLR_PORT!" (
if "%%x"=="0.0.0.0" (
@echo. @echo.
set has_info=1 set has_info=1
echo Found Solr process %%k running on port !SOME_SOLR_PORT! echo Found Solr process %%k running on port !SOME_SOLR_PORT!
@ -970,7 +957,6 @@ for /f "usebackq" %%i in (`dir /b "%SOLR_TIP%\bin" ^| findstr /i "^solr-.*\.port
) )
) )
) )
)
if NOT "!has_info!"=="1" echo No running Solr nodes found. if NOT "!has_info!"=="1" echo No running Solr nodes found.
set has_info= set has_info=
goto done goto done
@ -1084,7 +1070,7 @@ if "!CREATE_PORT!"=="" (
set SOME_SOLR_PORT= set SOME_SOLR_PORT=
For /F "Delims=" %%J In ('type "%SOLR_TIP%\bin\%%i"') do set SOME_SOLR_PORT=%%~J For /F "Delims=" %%J In ('type "%SOLR_TIP%\bin\%%i"') do set SOME_SOLR_PORT=%%~J
if NOT "!SOME_SOLR_PORT!"=="" ( if NOT "!SOME_SOLR_PORT!"=="" (
for /f "tokens=2,5" %%j in ('netstat -aon ^| find "TCP " ^| find ":!SOME_SOLR_PORT! "') do ( for /f "tokens=2,5" %%j in ('netstat -aon ^| find "TCP " ^| find ":0 " ^| find ":!SOME_SOLR_PORT! "') do (
IF NOT "%%k"=="0" set CREATE_PORT=!SOME_SOLR_PORT! IF NOT "%%k"=="0" set CREATE_PORT=!SOME_SOLR_PORT!
) )
) )
@ -1152,7 +1138,7 @@ if "!DELETE_PORT!"=="" (
set SOME_SOLR_PORT= set SOME_SOLR_PORT=
For /F "Delims=" %%J In ('type "%SOLR_TIP%\bin\%%i"') do set SOME_SOLR_PORT=%%~J For /F "Delims=" %%J In ('type "%SOLR_TIP%\bin\%%i"') do set SOME_SOLR_PORT=%%~J
if NOT "!SOME_SOLR_PORT!"=="" ( if NOT "!SOME_SOLR_PORT!"=="" (
for /f "tokens=2,5" %%j in ('netstat -aon ^| find "TCP " ^| find ":!SOME_SOLR_PORT! "') do ( for /f "tokens=2,5" %%j in ('netstat -aon ^| find "TCP " ^| find ":0 " ^| find ":!SOME_SOLR_PORT! "') do (
IF NOT "%%k"=="0" set DELETE_PORT=!SOME_SOLR_PORT! IF NOT "%%k"=="0" set DELETE_PORT=!SOME_SOLR_PORT!
) )
) )

View File

@ -66,6 +66,12 @@ set ENABLE_REMOTE_JMX_OPTS=false
REM The script will use SOLR_PORT+10000 for the RMI_PORT or you can set it here REM The script will use SOLR_PORT+10000 for the RMI_PORT or you can set it here
REM set RMI_PORT=18983 REM set RMI_PORT=18983
REM Set the host interface to listen on. Jetty will listen on all interfaces (0.0.0.0) by default.
REM This must be an IPv4 ("a.b.c.d") or bracketed IPv6 ("[x::y]") address, not a hostname!
set SOLR_JETTY_HOST=0.0.0.0
set SOLR_OPTS=%SOLR_OPTS% -Djetty.host=%SOLR_JETTY_HOST%
REM Set the thread stack size REM Set the thread stack size
set SOLR_OPTS=%SOLR_OPTS% -Xss256k set SOLR_OPTS=%SOLR_OPTS% -Xss256k