Deploying a Node.js Application to an ECS Instance

Develop an Application Locally

const http = require('http');
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Alibaba Cloud Toolkit: Hello World');
});
server.listen(port, '0.0.0.0', () => {});

Install Plug-in

Configure the Plug-in Preferences

Deploy the Application

source ~/.bash_profile
killall node
nohup node /root/nodejs-demo/helloworld.js > nohup.log 2>&1 &

Description of Deployment Parameters

  • Deploy File: Two options are available. The option Upload File is used for a Node. js project.
  • Maven Build: If Maven is used to build the current project, you can use Alibaba Cloud Toolkit to directly build and deploy the application.
  • Upload File: If Maven is not used to build the current project, or a locally packaged deployment file already exists, you can select and directly upload the local deployment file.
  • Target Deploy ECS: Select a region from the drop-down list, and then select the ECS instance to be deployed in the region.
  • Deploy Location: Enter the deployment path on the ECS instance, for example, /root/nodejs-demo.
  • Command: Enter the application startup command, for example, sh /root/nodejs-demo/restart.sh. This parameter specifies the command to be executed after the deployment is completed. For a Node.js program, this is usually the startup command node XXX.js.

--

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

More from Medium

Upload a docker image to DockerHub

Introduction To MongoDB

Adding correlation-id to Node.js express-based application with log4js

Flask JWT based Authentication and Authorization Library Survey