Common pm2 commands

Source: Internet
Author: User
Tags json memory usage reset

PM2 (source code on github) is an open-source Nodejs-based process manager, which provides a complete set of functions including daemon, monitoring, and logs, basically, it is the best daemon choice for Nodejs applications. In fact, it can not only start Nodejs programs, but also be competent as long as it is a general script program.

The following are common pm2 command lines:

$ Pm2 start app. js # start the app. js application
$ Pm2 start app. js-I 4 # cluster mode start four app. js application instances
# Four applications will automatically perform load balancing
$ Pm2 start app. js -- name = "api" # start the application and name it "api"
$ Pm2 start app. js -- watch # automatically restart the application when the file changes
$ Pm2 start script. sh # start the bash script


$ Pm2 list # list all applications started by PM2
$ Pm2 monit # displays the CPU and memory usage of each application
$ Pm2 show [app-name] # display all application information


$ Pm2 logs # display logs of all applications
$ Pm2 logs [app-name] # display logs of the specified application
$ Pm2 flush


$ Pm2 stop all # stop all applications
$ Pm2 stop 0 # stop a specified application with id 0
$ Pm2 restart all # restart all applications
$ Pm2 reload all # Restart all applications in cluster mode
$ Pm2 gracefulReload all # Graceful reload all apps in cluster mode
$ Pm2 delete all # close and delete all applications
$ Pm2 delete 0 # delete a specified application id 0
$ Pm2 scale api 10 # extend the application named api to 10 instances
$ Pm2 reset [app-name] # reset restart count


$ Pm2 startup # create an automatic startup command
$ Pm2 save # save the current application list
$ Pm2 resurrect # Reload the saved application list
$ Pm2 update # Save processes, kill PM2 and restore processes
$ Pm2 generate # Generate a sample json configuration file


$ Pm2 deploy app. json prod setup # Setup "prod" remote server
$ Pm2 deploy app. json prod # Update "prod" remote server
$ Pm2 deploy app. json prod revert 2 # Revert "prod" remote server by 2


$ Pm2 module: generate [name] # Generate sample module with name [name]
$ Pm2 install pm2-logrotate # Install module (here a log rotation system)
$ Pm2 uninstall pm2-logrotate # Uninstall module
$ Pm2 publish # Increment version, git push and npm publish

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.