Windows service: Use JAVA_HOME environment variable in registry

This allows for updating Java without having to re-install the service.

Closes #13521
This commit is contained in:
gmarz 2016-02-09 14:29:16 -05:00
parent 4decc72da6
commit 7a969c0bbe
1 changed files with 14 additions and 11 deletions

View File

@ -110,21 +110,24 @@ echo Installing service : "%SERVICE_ID%"
echo Using JAVA_HOME (%ARCH%): "%JAVA_HOME%" echo Using JAVA_HOME (%ARCH%): "%JAVA_HOME%"
rem Check JVM server dll first rem Check JVM server dll first
set JVM_DLL=%JAVA_HOME%\jre\bin\server\jvm.dll if exist "%JAVA_HOME%"\jre\bin\server\jvm.dll (
if exist "%JVM_DLL%" goto foundJVM set JVM_DLL=\jre\bin\server\jvm.dll
goto foundJVM
)
rem Check 'server' JRE (JRE installed on Windows Server) rem Check 'server' JRE (JRE installed on Windows Server)
set JVM_DLL=%JAVA_HOME%\bin\server\jvm.dll if exist "%JAVA_HOME%"\bin\server\jvm.dll (
if exist "%JVM_DLL%" goto foundJVM set JVM_DLL=\bin\server\jvm.dll
goto foundJVM
)
rem Fallback to 'client' JRE rem Fallback to 'client' JRE
set JVM_DLL=%JAVA_HOME%\bin\client\jvm.dll if exist "%JAVA_HOME%"\bin\client\jvm.dll (
set JVM_DLL=\bin\client\jvm.dll
if exist "%JVM_DLL%" ( echo Warning: JAVA_HOME points to a JRE and not JDK installation; a client (not a server^) JVM will be used...
echo Warning: JAVA_HOME points to a JRE and not JDK installation; a client (not a server^) JVM will be used...
) else ( ) else (
echo JAVA_HOME points to an invalid Java installation (no jvm.dll found in "%JAVA_HOME%"^). Existing... echo JAVA_HOME points to an invalid Java installation (no jvm.dll found in "%JAVA_HOME%"^). Exiting...
goto:eof goto:eof
) )
:foundJVM :foundJVM
@ -159,7 +162,7 @@ if not "%ES_JAVA_OPTS%" == "" set JVM_OPTS=%JVM_OPTS%;%JVM_ES_JAVA_OPTS%
if "%ES_START_TYPE%" == "" set ES_START_TYPE=manual if "%ES_START_TYPE%" == "" set ES_START_TYPE=manual
if "%ES_STOP_TIMEOUT%" == "" set ES_STOP_TIMEOUT=0 if "%ES_STOP_TIMEOUT%" == "" set ES_STOP_TIMEOUT=0
"%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%" --JvmSs %JVM_SS% --JvmMs %JVM_XMS% --JvmMx %JVM_XMX% --JvmOptions %JVM_OPTS% ++JvmOptions %ES_PARAMS% %LOG_OPTS% --PidFile "%SERVICE_ID%.pid" --DisplayName "Elasticsearch %ES_VERSION% (%SERVICE_ID%)" --Description "Elasticsearch %ES_VERSION% Windows Service - http://elasticsearch.org" --Jvm "%JVM_DLL%" --StartMode jvm --StopMode jvm --StartPath "%ES_HOME%" ++StartParams start "%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%" --JvmSs %JVM_SS% --JvmMs %JVM_XMS% --JvmMx %JVM_XMX% --JvmOptions %JVM_OPTS% ++JvmOptions %ES_PARAMS% %LOG_OPTS% --PidFile "%SERVICE_ID%.pid" --DisplayName "Elasticsearch %ES_VERSION% (%SERVICE_ID%)" --Description "Elasticsearch %ES_VERSION% Windows Service - http://elasticsearch.org" --Jvm "%%JAVA_HOME%%%JVM_DLL%" --StartMode jvm --StopMode jvm --StartPath "%ES_HOME%" ++StartParams start
if not errorlevel 1 goto installed if not errorlevel 1 goto installed