-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Make nodejs configurable like JAVA #234720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Make it configurable, which version of nodejs the user can use, analog to JAVA. This way either users can provide their own version of nodejs or Kibana can ship with two, one with glibc2.17 support for RHEL7 and one for modern glibc so users can switch.
|
Thanks for the PR! Adding a diff --git a/src/dev/build/tasks/bin/scripts/kibana b/src/dev/build/tasks/bin/scripts/kibana
index 1e2b1ba65a8..70b3ce5d08c 100755
--- a/src/dev/build/tasks/bin/scripts/kibana
+++ b/src/dev/build/tasks/bin/scripts/kibana
@@ -28,20 +28,25 @@ if [ -f "${CONFIG_DIR}/node.options" ]; then
KBN_NODE_OPTS="$(grep -v ^# < ${CONFIG_DIR}/node.options | xargs)"
fi
-{{#darwin}}
-NODE="${DIR}/node/default/bin/node"
-{{/darwin}}
-{{#linux}}
-NODE="${DIR}/node/glibc-217/bin/node"
-{{#serverless}}
-if [ "$KBN_ENABLE_POINTER_COMPRESSION" = 'true' ]; then
+if [ -n "$KBN_NODE_HOME" ]; then
+ NODE="${KBN_NODE_HOME}/bin/node"
+else
+ {{#darwin}}
+ NODE="${DIR}/node/default/bin/node"
+ {{/darwin}}
+ {{#linux}}
+ NODE="${DIR}/node/glibc-217/bin/node"
+ {{#serverless}}
+ if [ "$KBN_ENABLE_POINTER_COMPRESSION" = 'true' ]; then
+ NODE="${DIR}/node/pointer-compression/bin/node"
+ fi
+ {{/serverless}}
+ {{#forcePointerCompression}}
NODE="${DIR}/node/pointer-compression/bin/node"
+ {{/forcePointerCompression}}
+ {{/linux}}
fi
-{{/serverless}}
-{{#forcePointerCompression}}
-NODE="${DIR}/node/pointer-compression/bin/node"
-{{/forcePointerCompression}}
-{{/linux}}
test_node
# Enable capturing heap snapshots. See https://nodejs.org/api/cli.html#--heapsnapshot-signalsignal
diff --git a/src/dev/build/tasks/bin/scripts/kibana.bat b/src/dev/build/tasks/bin/scripts/kibana.bat
index 80040138cd8..165a2047bb4 100755
--- a/src/dev/build/tasks/bin/scripts/kibana.bat
+++ b/src/dev/build/tasks/bin/scripts/kibana.bat
@@ -5,7 +5,11 @@ SETLOCAL ENABLEDELAYEDEXPANSION
set SCRIPT_DIR=%~dp0
for %%I in ("%SCRIPT_DIR%..") do set DIR=%%~dpfI
-set NODE=%DIR%\node\default\node.exe
+If Not "%KBN_NODE_HOME%"=="" (
+ set "NODE=%KBN_NODE_HOME%\bin\node.exe"
+) Else (
+ set "NODE=%DIR%\node\default\node.exe"
+)
set NODE_ENV=production
If Not Exist "%NODE%" (A little more complexity, but makes it work in all our environments. Also a few notes for kibana.bat. If this makes sense to you we can also make updates to all the bin scripts in this folder, and add a note in our documentation. |
|
Pinging @elastic/kibana-operations (Team:Operations) |
|
Hi, thank you for the hint about the KBN_ style environment variables, I missed this. You are right, we could expand on this PR and I could add this to the other scripts in the directory. I'd only update the *nix scipts though. I am unfamiliar with the Windows environment, so would like to leave this to someone else. I'd use a construct like this though: |
This generalizes the use of KBN_NODE_DIR to all environments
Add KBN_NODE_HOME handling for Windows
|
@jbudz I now amended all files as suggested. |
Summary
This change proposes a new environment variable $KBN_NODE_HOME , which will make it possible to switch the nodejs implementation that kibana uses. This is supposed to work analog to the $ES_JAVA_HOME variable.
"/bin/node" is appended to $KBN_NODE_HOME as the expected full path to the binary.
By providing KBN_NODE_HOME you can provide the path to a nodejs implementation that for example is not dependent on glibc-2.17 . Kibana could then ship with two nodejs binaries, one with glibc-2.17 support for RHEL 7 and one with support for modern glibc to offer an upgrade path away from the custom nodejs port.
By default (no environment variable is set) the current behaviour is preserved.
Identify risks
Supplying your own nodejs can break compatiblity, may lead to loss of data and invalidate support.
Release note
Provide an alternative nodejs binary via "KBN_NODE_HOME" environment variable, to support e.g. modern versions of glibc.