It is recommended to use the process managerpm2. For usage methods, please refer to the PM2 Practical Getting Started Guide summarized by the author before
Possible problems caused by the way the poster starts the service
Complicated operation: slightly
Poor service robustness: For example, if the program runs incorrectly, the server will hang up, and users will not be able to access it. At the very least, it needs to support automatic restart.
Other hidden dangers: After updating the service, such as modifying the configuration, etc., manual restart is required every time. Worse yet, you may simply forget to restart.
Reason for using pm2
Solve the above problem.
How to use
It is very simple to use, first install pm2
npm install -g pm2
Then use pm2 to start the program instead. --watch means monitoring the running status of the program. Once:
Recommendedpm2, supports watch automatic restart, automatic restart when memory limit is exceeded, scheduled restart, cluster, log capture, etc. It is still very convenient
It is recommended to use the process manager
pm2
. For usage methods, please refer to the PM2 Practical Getting Started Guide summarized by the author beforePossible problems caused by the way the poster starts the service
Complicated operation: slightly
Poor service robustness: For example, if the program runs incorrectly, the server will hang up, and users will not be able to access it. At the very least, it needs to support automatic restart.
Other hidden dangers: After updating the service, such as modifying the configuration, etc., manual restart is required every time. Worse yet, you may simply forget to restart.
Reason for using pm2
Solve the above problem.
How to use
It is very simple to use, first install
pm2
Then use
pm2
to start the program instead.--watch
means monitoring the running status of the program. Once:Service exception: automatic restart
Service changes: automatic restart
Others
It should not start when the user accesses it, but the server should always be started
You can take a look at forever or pm2
Recommended
pm2
, supports watch automatic restart, automatic restart when memory limit is exceeded, scheduled restart, cluster, log capture, etc. It is still very convenient