How to use pm2 to realize automatic restart script of CPu100% in node.js
This article will explain in detail how to use pm2 in node.js to occupy the CPu100% automatic restart script. The editor finds it very practical, so I share it with you for reference. I hope you can get something after reading this article.
The company uses nodejs to develop part of the business and uses pm2 to manage the node process.
But always inexplicably occupy 100%CPU, and for the time being can not find any problem.
In order to avoid business jam caused by the 100%CPU occupied by the node process, a script is written for pm2 to manage the node.js process.
Approximate way:
Use pm2 json to get current information about pm2.
If it is found that one of the processes in pm2 occupies CPU90%, and the corresponding log of that process has not changed within 5s, restart the process.
It can be regarded as a temporary cure rather than a permanent cure.
Use: php pm2AutoCheck.php 2 > & 1 > / dev/null &