Skip to content

Apache Lucene open-source search software

SOLR-9137: bin/solr script ignored custom STOP_PORT on shutdown. (Joachim Kohlhammer, Steve Rowe, Christine Poerschke)

Christine Poerschke9268b2b30fec
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index aaefff62989..456363f26e2 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -165,6 +165,9 @@ Bug Fixes
* SOLR-11687: SolrCore.getNewIndexDir falsely returns {dataDir}/index on any IOException reading index.properties
(Nikolay Martynov, Erick Erickson)
+* SOLR-9137: bin/solr script ignored custom STOP_PORT on shutdown.
+ (Joachim Kohlhammer, Steve Rowe, Christine Poerschke)
+
Optimizations
----------------------
* SOLR-11285: Refactor autoscaling framework to avoid direct references to Zookeeper and Solr
diff --git a/solr/bin/solr b/solr/bin/solr
index dd8d6efa21b..2fb483c826f 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -729,7 +729,7 @@ function stop_solr() {
DIR="$1"
SOLR_PORT="$2"
- STOP_PORT=`expr $SOLR_PORT - 1000`
+ STOP_PORT="${STOP_PORT:-$(expr $SOLR_PORT - 1000)}"
STOP_KEY="$3"
SOLR_PID="$4"
diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd
index 57e2e6218c7..035a9db5ad7 100644
--- a/solr/bin/solr.cmd
+++ b/solr/bin/solr.cmd
@@ -964,7 +964,7 @@ IF "%SCRIPT_CMD%"=="stop" (
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
+ IF "%STOP_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
@@ -994,7 +994,7 @@ IF "%SCRIPT_CMD%"=="stop" (
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
+ IF "%STOP_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