Pm2 can be used to manage project start and stop.

The public good service has been repaired in these two days. The reason for the failure of the service is that I modified the configuration of nginx before. The original public account service was under the root directory, but after modification, the corresponding service could not be found. Change a directory, the directory proxy to the corresponding port service is good.

Start the

pm2 start app.js
Copy the code

We can launch various applications such as:Bash command.scriptAnd so on.

pm2 start "npm run start"
pm2 start "ls -a"
pm2 start app.py
Copy the code

According to the log

You can use the –attach parameter to display logs when the application is started

pm2 start app.js --attach
Copy the code

Passing parameters

Anything that follows the — will be passed as arguments to the launching application

pm2 start app.js -- arg1 arg2 ...
Copy the code

The configuration file

If multiple applications need to be managed, you can manage them using configuration files

// conf.js
module.exports = {
  apps : [{
    name   : "limit worker".script : "./worker.js".args   : "limit"}, {name   : "rotate worker".script : "./worker.js".args   : "rotate"}}]Copy the code

At the start

pm2 start conf.js
Copy the code

Restart the application

pm2 restart app

// Restart all
pm2 restart all

// Restart the specified application

pm2 restart app1 app2 app3
Copy the code

Stop the application

pm2 stop app

// Stop all
pm2 stop all

// Stop the specified application

pm2 stop app1 app2 app3
Copy the code

Delete the application

// Delete the specified application
pm2 delete app

// Delete all
pm2 delete all
Copy the code

Display all applications

pm2 list 

/ / or

pm2 [list|ls|l|status]
Copy the code

Display specified applications

pm2 list --sort name:desc
/ / or
pm2 list --sort [name|id|cup|status]
Copy the code

Display terminal

You can run the pm2 monit command to view the resource usage

pm2 monit
Copy the code

Example View application meta information

You can run the pm2 show app command to view application meta information

pm2 show app
Copy the code

One last word

  1. Move your small hands to make a fortune, “like it”
  2. Move your small hands to make a fortune, “a point to see”
  3. If you see it here, you might as well “add a follow”.
  4. You might as well “retweet” and remember to share good things

Click to add a follow