https://github.com/kgrid/kgrid-node-runtime
929
KGrid Node Runtime, enabled by express server is a runtime that connects to the proxy adapter in an activator and can be used to run nodejs objects.
Make sure you have node.js 11.0 or later installed. To download and install the node runtime run
npm install -g @kgrid/noderuntime
current directory/kgrid_node/node and any node modules required by deployed endpoints will be stored in current directory/kgrid_node/node_modules. Because of this, it will require write access to its current directory.Download the latest image from docker hub: docker pull kgrid/kgrid-node-runtime:latest
Use the following command to run the image on Linux:
docker run --network host kgrid/kgrid-node-runtime
Or
docker run -it -p 3000:3000 -e KGRID_PROXY_ADAPTER_URL=http://host.docker.internal:8080 kgrid/kgrid-node-runtime
This starts the runtime pointed to an activator running on the same system at localhost:8080
The runtime exposes two endpoints which can be used to see the details of the runtime and what has been activated
GET /infoDisplays details about the runtime such as the running version and status.
GET /endpointsDisplays a list of the activated endpoints in the engine.
KGRID_PROXY_ADAPTER_URLhttp://localhost:8080KGRID_NODE_ENV_URLhttp://localhost:3000KGRID_NODE_ENV_PORT3000KGRID_PROXY_HEARTBEAT_INTERVAL30KGRID_NODE_LOAD_FROM_CACHEtrue means the node runtime will attempt to load endpoints from its internal cache on startup, and when receiving activation messagesfalse means the node runtime will always load endpoints new, and anything in its cache will be overwritten on startup, or when receiving activation messages.falseKGRID_NODE_SHELF_PATHshelf/proxy/artifacts endpoints.KGRID_NODE_LOAD_FROM_CACHE to trueNODE_PATHNODE_PATH to kgrid_node/node_modules in the current directory. Otherwise, your KO's will not be able to require node packages.
export NODE_PATH=$(pwd)/kgrid_node/node_modulesset NODE_PATH=%cd%\kgrid_node\node_modulesDEBUGtrue/falsefalseStart the runtime by running
kgrid-node
An example KO with naan of hello, a name of neighbor, api version of 1.0, and endpoint welcome,
a Deployment Specification might look like this:
/welcome:
post:
artifact:
- src/welcome.js
- src/helper-code.js
- package.json
engine: node
function: main
entry: src/welcome.js
Where engine is node, function is the name of the main entry function in the code and entry is the name of the file containing that function.
To use npm dependencies include a simple package.json file with a dependencies node. See the node/dependencies/v1.0 object for an example.
You would then execute this endpoint to see the code work:
POST <activator url>/<naan>/<name>/<api version>/<endpoint>
In this example: POST <activator url>/node/dependencies/1.0/welcome
An example KO can be found in our example collection here: node/simple/1.0
Content type
Image
Digest
Size
44.8 MB
Last updated
about 5 years ago
docker pull kgrid/kgrid-node-runtime