-
Notifications
You must be signed in to change notification settings - Fork 8
JAVA_HOME not set #7
Comments
I have a bunch of unsynced commits that makes a bunch of improvements and resolves the other issues. Thanks for finding this one. You saved me a bunch of debugging time. I will change the code so that JAVA_HOME is provided as an argument to the elasticsearch process. My ideal would be to install java to a custom directory and not have to mess with environment variables and the registry. The only problem with that approach is, in my view, the best way to know if java is installed is to read the registry. Lastly for the java and elasticsearch processes I am capturing StandardError once the process has ended. I will look into enabling events for trace information like you have. |
I was wrong. Don't know why I thought the batch file accepted java_home as an argument. However, I should be able to set custom Environment variables for the process and achieve the same effect. The reason elasticsearch isn't exiting is a "pause" in the batch script when it encounters the no JAVA_HOME error. |
So the JAVA_HOME issue is related to how processes get their environment variables. Apparently, they inherit them from their calling process. When you call SetEnviromentVariable a broadcast message (WM_SETTINGCHANGE) is sent to all processes informing them of the change. This is an async processes so even if your process handles that message, your operation which depends on the updated value could very well occur before this message is received. You can read more here. |
By setting the JAVA_HOME variable like this:
The variable gets picked up immediately and a recycle is not needed |
I added some more logging and have found the reason why Elastic search does not start on new instances during scaling.
When Elastic Search is started it complains about missing JAVA_HOME variable. This variable has been set, but is somehow not picked up.
By restarting the worker role everything works as expected.
By starting the Elastic Search process like this:
and the capturing the standardoutput like this:
It is possible to listen for the text "JAVA_HOME environment variable must be set!" which elasticsearch.bat file outputs and restart the worker role by throwing an exception. Not very elegant, but it works as a temporary solution.
The text was updated successfully, but these errors were encountered: