Fix path.conf usage on Windows

This commit addresses a change in core Elasticsearch where the
command-line flag --path.conf is no longer respected. Instead, the
configuration path must be passed through the system property
es.path.conf. We adapt the Windows batch file and the service for this
change.
This commit is contained in:
Jason Tedor 2017-07-28 23:52:51 +09:00
parent ec7ac32772
commit e508c277e1
3 changed files with 15 additions and 18 deletions

View File

@ -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

View File

@ -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

View File

@ -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%"