You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2016/04/28 06:10:14 UTC

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

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x ec071e2f8 -> 9e34d3137


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


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/9e34d313
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/9e34d313
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/9e34d313

Branch: refs/heads/branch_6x
Commit: 9e34d3137f6b5a90a207c86b88cdd6ba17f0553e
Parents: ec071e2
Author: Uwe Schindler <us...@apache.org>
Authored: Wed Apr 27 23:59:51 2016 +0200
Committer: Uwe Schindler <us...@apache.org>
Committed: Thu Apr 28 06:10:00 2016 +0200

----------------------------------------------------------------------
 solr/CHANGES.txt     |   3 ++
 solr/bin/solr.cmd    | 102 ++++++++++++++++++++--------------------------
 solr/bin/solr.in.cmd |   8 +++-
 3 files changed, 54 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e34d313/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index c9506f9..e725449 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -118,6 +118,9 @@ Bug Fixes
 
 * 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
 ----------------------
 * SOLR-8722: Don't force a full ZkStateReader refresh on every Overseer operation.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e34d313/solr/bin/solr.cmd
----------------------------------------------------------------------
diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd
index bc4e76a..6dce9b9 100644
--- a/solr/bin/solr.cmd
+++ b/solr/bin/solr.cmd
@@ -681,30 +681,24 @@ IF "%SCRIPT_CMD%"=="stop" (
       set found_it=0
       for /f "usebackq" %%i in (`dir /b "%SOLR_TIP%\bin" ^| findstr /i "^solr-.*\.port$"`) do (
         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!"=="" (
-          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
             IF NOT "%%k"=="0" (
-              @REM split the ip:port var by colon to see if the ip is 0.0.0.0
-              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
-                  @echo Stopping Solr process %%k running on port !SOME_SOLR_PORT!
-                  set /A STOP_PORT=!SOME_SOLR_PORT! - 1000
-                  "%JAVA%" %SOLR_SSL_OPTS% -Djetty.home="%SOLR_SERVER_DIR%" -jar "%SOLR_SERVER_DIR%\start.jar" STOP.PORT=!STOP_PORT! STOP.KEY=%STOP_KEY% --stop
-                  del "%SOLR_TIP%"\bin\solr-!SOME_SOLR_PORT!.port
-                  timeout /T 5
-                  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 (
-                    IF "%%N"=="%%k" (
-                      for /f "delims=: tokens=1,2" %%a IN ("%%M") do (
-                        IF "%%a"=="0.0.0.0" (
-                          @echo Forcefully killing process %%N
-                          taskkill /f /PID %%N
-                        )
-                      )
+              IF "%%j"=="%SOLR_JETTY_HOST%:!SOME_SOLR_PORT!" (
+                set found_it=1
+                @echo Stopping Solr process %%k running on port !SOME_SOLR_PORT!
+                set /A STOP_PORT=!SOME_SOLR_PORT! - 1000
+                "%JAVA%" %SOLR_SSL_OPTS% -Djetty.home="%SOLR_SERVER_DIR%" -jar "%SOLR_SERVER_DIR%\start.jar" STOP.PORT=!STOP_PORT! STOP.KEY=%STOP_KEY% --stop
+                del "%SOLR_TIP%"\bin\solr-!SOME_SOLR_PORT!.port
+                timeout /T 5
+                REM Kill it if it is still running after the graceful shutdown
+                For /f "tokens=2,5" %%M in ('netstat -nao ^| find "TCP " ^| find ":0 " ^| find ":!SOME_SOLR_PORT! "') do (
+                  IF "%%N"=="%%k" (
+                    IF "%%M"=="%SOLR_JETTY_HOST%:!SOME_SOLR_PORT!" (
+                      @echo Forcefully killing process %%N
+                      taskkill /f /PID %%N
                     )
                   )
                 )
@@ -720,25 +714,21 @@ IF "%SCRIPT_CMD%"=="stop" (
     )
   ) ELSE (
     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" (
-        for /f "delims=: tokens=1,2" %%x IN ("%%M") do (
-          IF "%%x"=="0.0.0.0" (
-            set found_it=1
-            @echo Stopping Solr process %%N running on port %SOLR_PORT%
-            set /A STOP_PORT=%SOLR_PORT% - 1000
-            "%JAVA%" %SOLR_SSL_OPTS% -Djetty.home="%SOLR_SERVER_DIR%" -jar "%SOLR_SERVER_DIR%\start.jar" "%SOLR_JETTY_CONFIG%" STOP.PORT=!STOP_PORT! STOP.KEY=%STOP_KEY% --stop
-            del "%SOLR_TIP%"\bin\solr-%SOLR_PORT%.port
-            timeout /T 5
-            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 (
-              IF "%%N"=="%%k" (
-                for /f "delims=: tokens=1,2" %%a IN ("%%j") do (
-                  IF "%%a"=="0.0.0.0" (
-                    @echo Forcefully killing process %%N
-                    taskkill /f /PID %%N
-                  )
-                )
+        IF "%%M"=="%SOLR_JETTY_HOST%:%SOLR_PORT%" (
+          set found_it=1
+          @echo Stopping Solr process %%N running on port %SOLR_PORT%
+          set /A STOP_PORT=%SOLR_PORT% - 1000
+          "%JAVA%" %SOLR_SSL_OPTS% -Djetty.home="%SOLR_SERVER_DIR%" -jar "%SOLR_SERVER_DIR%\start.jar" "%SOLR_JETTY_CONFIG%" STOP.PORT=!STOP_PORT! STOP.KEY=%STOP_KEY% --stop
+          del "%SOLR_TIP%"\bin\solr-%SOLR_PORT%.port
+          timeout /T 5
+          REM Kill it if it is still running after the graceful shutdown
+          For /f "tokens=2,5" %%j in ('netstat -nao ^| find "TCP " ^| find ":0 " ^| find ":%SOLR_PORT% "') do (
+            IF "%%N"=="%%k" (
+              IF "%%j"=="%SOLR_JETTY_HOST%:%SOLR_PORT%" (
+                @echo Forcefully killing process %%N
+                taskkill /f /PID %%N
               )
             )
           )
@@ -758,13 +748,11 @@ IF "%STOP_PORT%"=="" set /A STOP_PORT=%SOLR_PORT% - 1000
 
 IF "%SCRIPT_CMD%"=="start" (
   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" (
-      for /f "delims=: tokens=1,2" %%x IN ("%%j") do (
-        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"
-          goto err
-        )
+      IF "%%j"=="%SOLR_JETTY_HOST%:%SOLR_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
       )
     )
   )
@@ -954,18 +942,16 @@ for /f "usebackq" %%i in (`dir /b "%SOLR_TIP%\bin" ^| findstr /i "^solr-.*\.port
   set SOME_SOLR_PORT=
   For /F "Delims=" %%J In ('type "%SOLR_TIP%\bin\%%i"') do set SOME_SOLR_PORT=%%~J
   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" (
-        for /f "delims=: tokens=1,2" %%x IN ("%%j") do (
-          if "%%x"=="0.0.0.0" (
-            @echo.
-            set has_info=1
-            echo Found Solr process %%k running on port !SOME_SOLR_PORT!
-            "%JAVA%" %SOLR_SSL_OPTS% -Dsolr.install.dir="%SOLR_TIP%" -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
-              -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
-              org.apache.solr.util.SolrCLI status -solr !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!SOME_SOLR_PORT!/solr
-            @echo.
-          )
+        if "%%j"=="%SOLR_JETTY_HOST%:!SOME_SOLR_PORT!" (
+          @echo.
+          set has_info=1
+          echo Found Solr process %%k running on port !SOME_SOLR_PORT!
+          "%JAVA%" %SOLR_SSL_OPTS% -Dsolr.install.dir="%SOLR_TIP%" -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+            -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
+            org.apache.solr.util.SolrCLI status -solr !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!SOME_SOLR_PORT!/solr
+          @echo.
         )
       )
     )
@@ -1084,7 +1070,7 @@ if "!CREATE_PORT!"=="" (
     set SOME_SOLR_PORT=
     For /F "Delims=" %%J In ('type "%SOLR_TIP%\bin\%%i"') do set SOME_SOLR_PORT=%%~J
     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!
       )
     )
@@ -1152,7 +1138,7 @@ if "!DELETE_PORT!"=="" (
     set SOME_SOLR_PORT=
     For /F "Delims=" %%J In ('type "%SOLR_TIP%\bin\%%i"') do set SOME_SOLR_PORT=%%~J
     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!
       )
     )

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e34d313/solr/bin/solr.in.cmd
----------------------------------------------------------------------
diff --git a/solr/bin/solr.in.cmd b/solr/bin/solr.in.cmd
index 0b299af..9a8231c 100644
--- a/solr/bin/solr.in.cmd
+++ b/solr/bin/solr.in.cmd
@@ -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 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
 set SOLR_OPTS=%SOLR_OPTS% -Xss256k
 
@@ -97,4 +103,4 @@ REM otherwise keep them commented and the above values will automatically be set
 REM set SOLR_SSL_CLIENT_KEY_STORE=
 REM set SOLR_SSL_CLIENT_KEY_STORE_PASSWORD=
 REM set SOLR_SSL_CLIENT_TRUST_STORE=
-REM setSOLR_SSL_CLIENT_TRUST_STORE_PASSWORD=
\ No newline at end of file
+REM setSOLR_SSL_CLIENT_TRUST_STORE_PASSWORD=