diff --git a/distribution/src/main/resources/bin/elasticsearch-service.bat b/distribution/src/main/resources/bin/elasticsearch-service.bat index d3ec3fd60ba..9089f96bf97 100644 --- a/distribution/src/main/resources/bin/elasticsearch-service.bat +++ b/distribution/src/main/resources/bin/elasticsearch-service.bat @@ -126,8 +126,6 @@ if exist "%JAVA_HOME%\bin\client\jvm.dll" ( :foundJVM CALL "%ES_HOME%\bin\elasticsearch.in.bat" -if "%CONF_DIR%" == "" set CONF_DIR=%ES_HOME%\config - set ES_JVM_OPTIONS=%CONF_DIR%\jvm.options if not "%ES_JAVA_OPTS%" == "" set ES_JAVA_OPTS=%ES_JAVA_OPTS: =;% @@ -205,7 +203,7 @@ if "%JVM_SS%" == "" ( goto:eof ) -set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%" +set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.path.conf="%CONF_DIR%" if "%ES_START_TYPE%" == "" set ES_START_TYPE=manual if "%ES_STOP_TIMEOUT%" == "" set ES_STOP_TIMEOUT=0 @@ -219,7 +217,7 @@ if not "%SERVICE_USERNAME%" == "" ( ) ) -"%EXECUTABLE%" //IS//%SERVICE_ID% --Startup %ES_START_TYPE% --StopTimeout %ES_STOP_TIMEOUT% --StartClass org.elasticsearch.bootstrap.Elasticsearch --StopClass org.elasticsearch.bootstrap.Elasticsearch --StartMethod main --StopMethod close --Classpath "%ES_CLASSPATH%" --JvmMs %JVM_MS% --JvmMx %JVM_MX% --JvmSs %JVM_SS% --JvmOptions %ES_JAVA_OPTS% ++JvmOptions %ES_PARAMS% %LOG_OPTS% --PidFile "%SERVICE_ID%.pid" --DisplayName "%SERVICE_DISPLAY_NAME%" --Description "%SERVICE_DESCRIPTION%" --Jvm "%%JAVA_HOME%%%JVM_DLL%" --StartMode jvm --StopMode jvm --StartPath "%ES_HOME%" --StartParams --path.conf ++StartParams "%CONF_DIR%" %SERVICE_PARAMS% +"%EXECUTABLE%" //IS//%SERVICE_ID% --Startup %ES_START_TYPE% --StopTimeout %ES_STOP_TIMEOUT% --StartClass org.elasticsearch.bootstrap.Elasticsearch --StopClass org.elasticsearch.bootstrap.Elasticsearch --StartMethod main --StopMethod close --Classpath "%ES_CLASSPATH%" --JvmMs %JVM_MS% --JvmMx %JVM_MX% --JvmSs %JVM_SS% --JvmOptions %ES_JAVA_OPTS% ++JvmOptions %ES_PARAMS% %LOG_OPTS% --PidFile "%SERVICE_ID%.pid" --DisplayName "%SERVICE_DISPLAY_NAME%" --Description "%SERVICE_DESCRIPTION%" --Jvm "%%JAVA_HOME%%%JVM_DLL%" --StartMode jvm --StopMode jvm --StartPath "%ES_HOME%" %SERVICE_PARAMS% if not errorlevel 1 goto installed echo Failed installing '%SERVICE_ID%' service diff --git a/distribution/src/main/resources/bin/elasticsearch.bat b/distribution/src/main/resources/bin/elasticsearch.bat index 4f1a14849aa..def7410115e 100644 --- a/distribution/src/main/resources/bin/elasticsearch.bat +++ b/distribution/src/main/resources/bin/elasticsearch.bat @@ -35,19 +35,6 @@ FOR /F "usebackq tokens=1* delims= " %%A IN (!params!) DO ( SET HOSTNAME=%COMPUTERNAME% -if "%CONF_DIR%" == "" ( -rem '0' is the batch file, '~dp' appends the drive and path -set "ES_JVM_OPTIONS=%~dp0\..\config\jvm.options" -) else ( -set "ES_JVM_OPTIONS=%CONF_DIR%\jvm.options" -) - -@setlocal -rem extract the options from the JVM options file %ES_JVM_OPTIONS% -rem such options are the lines beginning with '-', thus "findstr /b" -for /F "usebackq delims=" %%a in (`findstr /b \- "%ES_JVM_OPTIONS%"`) do set JVM_OPTIONS=!JVM_OPTIONS! %%a -@endlocal & set ES_JAVA_OPTS=%JVM_OPTIONS% %ES_JAVA_OPTS% - CALL "%~dp0elasticsearch.in.bat" IF ERRORLEVEL 1 ( IF NOT DEFINED nopauseonerror ( @@ -56,6 +43,14 @@ IF ERRORLEVEL 1 ( EXIT /B %ERRORLEVEL% ) +set "ES_JVM_OPTIONS=%CONF_DIR%\jvm.options" + +@setlocal +rem extract the options from the JVM options file %ES_JVM_OPTIONS% +rem such options are the lines beginning with '-', thus "findstr /b" +for /F "usebackq delims=" %%a in (`findstr /b \- "%ES_JVM_OPTIONS%"`) do set JVM_OPTIONS=!JVM_OPTIONS! %%a +@endlocal & set ES_JAVA_OPTS=%JVM_OPTIONS% %ES_JAVA_OPTS% + %JAVA% %ES_JAVA_OPTS% %ES_PARAMS% -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" !newparams! ENDLOCAL diff --git a/distribution/src/main/resources/bin/elasticsearch.in.bat b/distribution/src/main/resources/bin/elasticsearch.in.bat index d7b985d0824..96c703c92e8 100644 --- a/distribution/src/main/resources/bin/elasticsearch.in.bat +++ b/distribution/src/main/resources/bin/elasticsearch.in.bat @@ -30,4 +30,8 @@ IF ERRORLEVEL 1 ( EXIT /B 1 ) -set ES_PARAMS=-Delasticsearch -Des.path.home="%ES_HOME%" +if "%CONF_DIR%" == "" ( +set "CONF_DIR=%~dp0\..\config" +) + +set ES_PARAMS=-Delasticsearch -Des.path.home="%ES_HOME%" -Des.path.conf="%CONF_DIR%"