Deploying Node.js servers using deployment REST APIs
You can deploy Node.js applications as members of a collective using the DeployService REST APIs. A Node.js collective member is called a Node.js server in this documentation.
Before you begin
Determine the target hosts onto which you want to install Node.js servers. Install Node.js V4 and the apiconnect-collective-member npm package on the target hosts. The command to install support for Node.js servers on Linux is:
npm install -g apiconnect-collective-member
Liberty supports Node versions 4.x and 6.x.
After installing Node.js, run node --version
from a command line at the Node.js
installation directory to ensure you have a supported Node version; for example:
C:\nodejs>node --version
v4.7.3
Each target host needs RXA or SSH. See Setting up RXA for Liberty collective operations.
Procedure
What to do next
Request and review the deployment status and results.
- Get a list of deployment tokens for requested deployment
operations.
GET https://controller_host:controller_port/ibm/api/collective/v1/deployment/deploy
- Get a short status of the deployment operations. Use the token from step 6 for
{token}
. Thus, for a{"id":3}
return token from step 6, use3
for{token}
.
During deployment, the API returns IN_PROGRESS:GET https://controller_host:controller_port/ibm/api/collective/v1/deployment/{token}/status
After deployment, the API returns FINISHED:{"status":{"target_host":"IN_PROGRESS"}}
{"status":{"target_host":"FINISHED"}}
You can also get a final status of ERROR if the deployment has problems. Use the following information to get the complete results. The
stdout
andstderr
information that is returned can help you diagnose the problems. - Get the complete results of a deployment operation. Use the token from step 6 for
{token}
. Thus, for a{"id":3}
return token from step 6, use3
for{token}
.
After deployment completes, the results contain information about the operation. The following example shows results for FINISHED:GET https://controller_host:controller_port/ibm/api/collective/v1/deployment/{token}/results
{"results":[{"host_name":"target_host","status":"FINISHED","result":0,"stdout":"deployment_stdout", "stderr":"deployment_stderr", "deployedArtifactName":"serverName_from_inputVars", "deployedUserDir":"target_host_directory_for_deployed_server"}]}
- Undeploy a Node.js
server.
POST https://controller_host:controller_port/ibm/api/collective/v1/deployment/undeploy { "host": "myHostName", "userDir":"/root/wlpn", "serverName":"myServerName" }
- Get a list of tokens for undeployment
operations.
To get status and results, follow steps similar to deployments.GET https://controller_host:controller_port/ibm/api/collective/v1/deployment/undeploy