How to use pm2 on the server

express project, and then if there is anything wrong, it will cause the whole project card to fall off. How to deploy pm2 to the server? I have tried to test on this machine. The same error running the project using pm2 will not make the whole project card fall off, but I don"t know how to use it on the server

.
Mar.06,2021

the local machine and the server are the same.

use the server as you use it on this computer.


just write pm2 directly into the dependency package of package.json, and then

{
  "scripts": {
    "start": "pm2 start app.js",
    "stop": "pm2 kill"
  }
}

then use npm start and npm stop to start and stop
logs are printed in ~ / .pm2 by default, and go to the official Internet cafe for detailed configuration.

Menu