PM2 is a node process management tool. It can be used to simplify many node application management tasks, such as performance monitoring, automatic restart, load balancing, and so on.
Global installation couldn't be simpler. npm install -g pm2Copy the code
Use the Express application as an example. We usually start the application with NPM start, which is called node./bin/ WWW.
Pm2 start./bin/ WWW --watch(--watch) If you want to precisely listen on and not listen on directories, it is best to use configuration files.Copy the code
restart
pm2 restart ./bin/www
Copy the code
stop
Stop a specific application. You can obtain the application name (specified by --name) or process ID by using pm2 list. pm2 stop app_name|app_idCopy the code
If you want to stop all applications, yes
pm2 stop all
Copy the code
delete
Similar pm2 stop, the pm2 delete app_name | app_id pm2 delete allCopy the code
Viewing process Status
pm2 list
Copy the code
See the log
Pm2 logs ID (service ID)Copy the code