Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PM2 does not restart crashed processes #5396

Merged
merged 1 commit into from Sep 8, 2022

Conversation

neilgupta
Copy link
Contributor

With autorestart set to true, PM2 will restart child processes if they disconnect. However, if the process crashes internally, PM2 will not attempt to restart or replace it, leaving the overall service running with one less process.

In our case, we just upgraded to node 16 and PM2 5.2.0, and are seeing node periodically throw ERR_IPC_CLOSED now. We're not sure about the root cause of that error yet, but regardless, we would expect PM2 to either handle that or at least restart the crashed process. Unfortunately, it's doing neither and just letting the process permanently die.

This appears to be because PM2 marks the process as ERRORED_STATUS in its error event handler, and ERRORED_STATUS processes do not even attempt to restart.

My proposed fix here skips marking the process as ERRORED_STATUS on a single error event, instead reserving that status for repeated crashes. This is the simplest solution, but I'm open to other ideas/approaches here.

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
License MIT

@CLAassistant
Copy link

CLAassistant commented Jul 1, 2022

CLA assistant check
All committers have signed the CLA.

@Unitech Unitech merged commit b3b2ca7 into Unitech:development Sep 8, 2022
@Unitech
Copy link
Owner

Unitech commented Sep 8, 2022

good catch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants