pm2 is a process manager for Node applications with load balancing function. You can put your standalone code to utilize all CPUs on all servers and ensure that the process is always alive with 0 seconds of reload.
The main features of pm2:
1. Built-in load balancing (using Node cluster cluster module)
2. Background running
3. 0-second shutdown and reload
4. Startup scripts with Ubuntu and CentOS
5. Stop unstable processes (avoid infinite loops)
6. Console detection
7. Provide HTTP API
8, remote control and real-time interface API (Nodejs module, allowing interaction with PM2 process manager)
PM2 installation:
Usage of pm2:
Different ways of running the process of pm2:
Common command usage:
pm2 list
Lists all process information managed by pm2, and also displays how many times a process will be started due to unhandled exceptions.
pm2 monit
Monitor the CPU and memory usage of each node process
The above is me I compiled it for everyone, I hope it will be helpful to everyone in the future.
Related articles:
How to submit a request using JS using POST method (detailed answer combined with code)
jsExecute an instance of a function after the code delays for a certain period of time
Avalonjs Implement a simple shopping cart function
The above is the detailed content of How to use pm2 in Node.js (graphic tutorial). For more information, please follow other related articles on the PHP Chinese website!