Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use pm2 to realize automatic restart script of CPu100% in node.js

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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 &

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report