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 restarts app when a subprocess was killed by the OOM killer #5941

Open
Choppel opened this issue Jan 31, 2025 · 0 comments
Open

PM2 restarts app when a subprocess was killed by the OOM killer #5941

Choppel opened this issue Jan 31, 2025 · 0 comments

Comments

@Choppel
Copy link

Choppel commented Jan 31, 2025

I have a node app running via pm2. The app itself spawns some processes like imagemagick's convert to convert some images in a folder. It can happen, that the convert call may use too much memory and get killed by the systems OOM killer with the message:

Out of memory: Killed process 111337 (convert) total-vm:562060kB, anon-rss:416096kB, file-rss:4kB, shmem-rss:67340kB, UID:0 pgtables:1060kB oom_score_adj:1000

This is fine. In this case my app would log an error that this process was not successful.

However, right after the OOM killer killed the sub process, pm2 kills my node app with the following message:

systemd[1]: pm2-root.service: A process of this unit has been killed by the OOM killer.
pm2[111342]: [PM2] Applying action deleteProcessId on app [all](ids: [ 0, 1, 2 ])

It seems, that pm2 detects that the OOM killer killed a sub process and then calls an internal method deleteProcessId on all apps.
Because of this, my app cannot log any error. It does get restarted, but then tries the same file until it gets killed again.
Is this the default behavior of pm2? Can this behavior be bypassed?

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

No branches or pull requests

1 participant