opendistro-for-elasticsearch / performance-analyzer

📈 OpenDistro Performance Analyzer
https://opendistro.github.io/
Apache License 2.0
146 stars 49 forks source link

performance-analyzer-agent does not use JAVA_HOME passed by parameter #302

Open sbruno opened 3 years ago

sbruno commented 3 years ago

performance-analyzer-agent allows setting a specific ES_HOME path as first argument and a JAVA_HOME path as second argument. In fact, the installation in a non-systemd system suggests using this command for starting it:

sh /usr/share/elasticsearch/plugins/opendistro-performance-analyzer/pa_bin/performance-analyzer-agent /usr/share/elasticsearch -d

OpenDistro documentation specifies to install JDK in the system, however elasticsearch has its embedded JDK and is possible to use it without installing other JDK, so this command could be used for starting the agent: sh /usr/share/elasticsearch/plugins/opendistro-performance-analyzer/pa_bin/performance-analyzer-agent /usr/share/elasticsearch /usr/share/elasticsearch/jdk -d

The problem is that even though the folder exist and is valid, it is not taken into account and displays the message: ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

This happens because inside the script, JAVA_HOME is defined as a variable but the agent is started using exec, and the variable is not available in its environment.

This works if JAVA_HOME is exported, in a similar way as JAVA_OPTS is exported in the same script.