This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/solr.git

commit c7178d186c326a0bc72e1cf2692a5a10fb6d6bac
Author: Jan Høydahl <[email protected]>
AuthorDate: Fri Nov 13 22:04:33 2026 +0100

    SOLR-18644: bin/solr.cmd should honour SOLR_PID_DIR (#5325)
    
    (cherry picked from commit 686f3e02d459d63ee1abdc5e4282068e980da355)
---
 .../SOLR-18644-solr-cmd-honours-solr-pid-dir.yml          | 14 ++++++++++++++
 solr/bin/solr.cmd                                         | 15 +++++++++------
 solr/bin/solr.in.cmd                                      |  4 ++++
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/changelog/unreleased/SOLR-18644-solr-cmd-honours-solr-pid-dir.yml 
b/changelog/unreleased/SOLR-18644-solr-cmd-honours-solr-pid-dir.yml
new file mode 100644
index 00000000000..cabb2ffcf28
--- /dev/null
+++ b/changelog/unreleased/SOLR-18644-solr-cmd-honours-solr-pid-dir.yml
@@ -0,0 +1,14 @@
+# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
+
+title: >
+  `bin\solr.cmd` now honours the `SOLR_PID_DIR` environment variable, instead 
of always writing the
+  files that record running nodes into the installation's `bin` directory. 
`bin/solr` and
+  `SolrProcessManager` already read it, so Windows now behaves like the other 
platforms and like the
+  documentation.
+type: fixed
+authors:
+  - name: Jan Høydahl
+    url: https://home.apache.org/phonebook.html?uid=janhoy
+links:
+  - name: SOLR-18644
+    url: https://issues.apache.org/jira/browse/SOLR-18644
diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd
index 1adde3d449d..dfda12a3bfd 100755
--- a/solr/bin/solr.cmd
+++ b/solr/bin/solr.cmd
@@ -32,6 +32,9 @@ pushd %SOLR_TIP%
 set SOLR_TIP=%CD%
 popd
 
+REM Where the per-node files recording running Solr instances live
+IF NOT DEFINED SOLR_PID_DIR set "SOLR_PID_DIR=%SOLR_TIP%\bin"
+
 REM Used to report errors before exiting the script
 set SCRIPT_ERROR=
 set NO_USER_PROMPT=0
@@ -827,9 +830,9 @@ IF "%SOLR_PORT_LISTEN%"=="" (
   IF "%STOP_ALL%"=="1" (
     REM Stop all running Solr instances
     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_PID_DIR%" ^| 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_PID_DIR%\%%i"') do set 
SOME_SOLR_PORT=%%~J
       if NOT "!SOME_SOLR_PORT!"=="" (
         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
@@ -843,7 +846,7 @@ IF "%SOLR_PORT_LISTEN%"=="" (
                 set LOCAL_STOP_PORT=%STOP_PORT%
               )
               "%JAVA%" %SOLR_SSL_OPTS% -Djetty.home="%SOLR_SERVER_DIR%" -jar 
"%SOLR_SERVER_DIR%\start.jar" STOP.PORT=!LOCAL_STOP_PORT! STOP.KEY=%STOP_KEY% 
--stop
-              del "%SOLR_TIP%"\bin\solr-!SOME_SOLR_PORT!.port
+              del "%SOLR_PID_DIR%"\solr-!SOME_SOLR_PORT!.port
               REM wait for the process to terminate
               CALL :wait_for_process_exit %%k !SOLR_STOP_WAIT!
               REM Kill it if it is still running after the graceful shutdown
@@ -872,7 +875,7 @@ IF "%SOLR_PORT_LISTEN%"=="" (
         @echo Stopping Solr process %%N running on port %SOLR_PORT_LISTEN%
         IF "%STOP_PORT%"=="" set /A STOP_PORT=%SOLR_PORT_LISTEN% - 1000
         "%JAVA%" %SOLR_SSL_OPTS% %SOLR_TOOL_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_LISTEN%.port
+        del "%SOLR_PID_DIR%"\solr-%SOLR_PORT_LISTEN%.port
         REM wait for the process to terminate
         CALL :wait_for_process_exit %%N !SOLR_STOP_WAIT!
         REM Kill it if it is still running after the graceful shutdown
@@ -1169,7 +1172,7 @@ IF NOT EXIST "%SOLR_SERVER_DIR%\tmp" (
 IF "%FG%"=="1" (
   REM run solr in the foreground
   title "Solr-%SOLR_PORT_LISTEN%"
-  echo %SOLR_PORT_LISTEN%>"%SOLR_TIP%"\bin\solr-%SOLR_PORT_LISTEN%.port
+  echo %SOLR_PORT_LISTEN%>"%SOLR_PID_DIR%"\solr-%SOLR_PORT_LISTEN%.port
   "%JAVA%" %SERVEROPT% %SOLR_JAVA_MEM% %START_OPTS% ^
     -Dlog4j.configurationFile="%LOG4J_CONFIG%" -DSTOP.PORT=!STOP_PORT! 
-DSTOP.KEY=%STOP_KEY% ^
     -Dsolr.solr.home="%SOLR_HOME%" -Dsolr.install.dir="%SOLR_TIP%" 
-Dsolr.install.symDir="%SOLR_TIP%" ^
@@ -1183,7 +1186,7 @@ IF "%FG%"=="1" (
     -Dsolr.solr.home="%SOLR_HOME%" -Dsolr.install.dir="%SOLR_TIP%" 
-Dsolr.install.symDir="%SOLR_TIP%" ^
     -Dsolr.port.listen=%SOLR_PORT_LISTEN% -Djetty.home="%SOLR_SERVER_DIR%" ^
     -Djava.io.tmpdir="%SOLR_SERVER_DIR%\tmp" -jar start.jar 
%SOLR_JETTY_CONFIG% "%SOLR_JETTY_ADDL_CONFIG%" > 
"!SOLR_LOGS_DIR!\solr-%SOLR_PORT_LISTEN%-console.log"
-  echo %SOLR_PORT_LISTEN%>"%SOLR_TIP%"\bin\solr-%SOLR_PORT_LISTEN%.port
+  echo %SOLR_PORT_LISTEN%>"%SOLR_PID_DIR%"\solr-%SOLR_PORT_LISTEN%.port
 
   IF "!SOLR_START_WAIT!"=="" (
     set SOLR_START_WAIT=180
diff --git a/solr/bin/solr.in.cmd b/solr/bin/solr.in.cmd
index 81be993aa47..cc488390828 100755
--- a/solr/bin/solr.in.cmd
+++ b/solr/bin/solr.in.cmd
@@ -98,6 +98,10 @@ REM Most properties have an environment variable equivalent.
 REM A naming convention is that SOLR_FOO_BAR maps to solr.foo.bar
 REM SOLR_CLUSTERING_ENABLED=true
 
+REM Location where the bin\solr script will save the files recording running 
instances
+REM If not set, the script will create them in %SOLR_TIP%\bin
+REM set SOLR_PID_DIR=
+
 REM Path to a directory for Solr to store cores and their data. By default, 
Solr will use server\solr
 REM If solr.xml is not stored in ZooKeeper, this directory needs to contain 
solr.xml
 REM set SOLR_HOME=

Reply via email to