It is possible to set environment variables and arguments for node.js scripts in the ScriptTarget tag. It also appears that some environment variables may already be defined, but I cannot find any documentation on the node.js environment. What environment variables are set when a node.js script starts running? Is it possible to determine the environment (i.e., test/prod/...) and organization before a request comes into the node.js application?
Solved! Go to Solution.
@Eric Hildum - As you may already know, this is the documentation page that talks about how to set environment variables and arguments to the node.js process: http://apigee.com/docs/api-services/content/understanding-edge-support-nodejs-modules#advancedscript...
<ScriptTarget> <ResourceURL>node://hello-world.js</ResourceURL> <EnvironmentVariables> <EnvironmentVariable name="NAME">VALUE</EnvironmentVariable> </EnvironmentVariables> <Arguments> <Argument>ARG</Argument> </Arguments> </ScriptTarget>
Q1 - What environment variables are set when a node.js script starts running?
You can easily find this out with this node.js code:
console.log('environment variables: ' + JSON.stringify(process.env));
When I execute this in my free org, I get:
{ "TERM": "xterm", "JAVA_HOME": "/usr/lib/jvm/java-1.7.0-openjdk.x86_64", "SHLVL": "3", "XFILESEARCHPATH": "/usr/dt/app-defaults/%L/Dt", "APIGEE_HOME": "/opt/apigee", "microkernel_overrideTokenFolder": "/opt/apigee/token", "working_dir": "/opt/apigee/apigee-1.0.0.974.5491b78.1507171825/bin", "microkernel_host": "rmp69apigee", "PWD": "/", "microkernel_overrideTokenDirs": "application region pod org host", "LOGNAME": "apigee", "_APIGEE_APP_ID": "V+/lh17zvLtIy1TWFLWYv2zZxvWDlvFgMFMcCjglDfM=", "_": "/usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/java", "microkernel_defaultTokenFolder": "/opt/apigee/apigee-1.0.0.974.5491b78.1507171825/token", "NLSPATH": "/usr/dt/lib/nls/msg/%L/%N.cat", "microkernel_timeout": "T60", "SHELL": "/bin/bash", "TMPDIR": "/tmp" "microkernel_hasMonetization": "false", "USE_TOKENIZED_CONFIG": "true", "microkernel_org": "default", "PATH": "/sbin:/usr/sbin:/bin:/usr/bin", "microkernel_application": "message-processor", "microkernel_installType": "cloud", "microkernel_instanceType": "c3.xlarge", "USER": "apigee", "HOME": "/home/apigee", "APIGEE_ORGANIZATION": "oseymen", "CONFIG_UTIL_HOME": "/opt/apigee/apigee-1.0.0.974.5491b78.1507171825/bin", "microkernel_pod": "rea1gw012", "APIGEE_ENVIRONMENT": "test", "microkernel_defaultTokenDirs": "application installType:application instanceType timeout", "microkernel_region": "us-east-1", "LANG": "en_US.UTF-8" }
Q2 - Is it possible to determine the environment (i.e., test/prod/...) and organization before a request comes into the node.js application?
I am not 100% on what you mean by "before request comes into node.js application", but here are a couple of pointers:
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |