Once the NodeJS application is developed and tested, the next step is to deploy it.

Using an open source tool, PM2, the whole deployment process was made surprisingly easy.

The installation is simple: NPM install -g pm2

Use the pm2 examples command to see some examples:

  • Start and add a process to the pm2 process list:

    pm2 start app.js –name app
  • Show the process list:

    pm2 1s
  • Stop and delete a process from the pm2 process list:

    $ pm2 delete app
  • Stop, start and restart a process from the process list:

    $ pm2 stop app pm2 start app$ pm2 restart app

Let’s try it.

I used Nodejs to develop a very simple web server, demoserver.js:

Command line to start the application:

pm2 start demoServer.js –name jerry

After startup, the system automatically displays the running status of the application, including the total running time, CPU usage, and memory usage.

You can run the pm2 list command to view the list of all applications started in PM2 mode.

Pm2 describe + has the same syntax as Kubernetes for viewing details of a POD.

Use ‘pm2 show’ to get more details about an appbuntuaip-172-31-12-185:~/sandbox/miniserver$pm2 describe 3Describing process with id 3-name jerry

Pm2 logs Enables you to view logs that are continuously refreshed in real time:

For more of Jerry’s original articles, please follow the public account “Wang Zixi “: [External link image transfer failed (img-pxjryukt-1567998311903)(upload-images.jianshu. IO /upload_imag… “: Outside the chain picture archiving failure (img – qAYtCKY9-1567998311905) (https://user-images.githubusercontent.com/5669954/60097669-68224900-9786-11e9-9f1e -e8bee08db4fa.png)]