Question

pm2 kills app process at random time

hello , i have problem that pm2 kill a specific app process ( nest.js node.js. api ) at random time either weekly or daily with no reason and even if no errors in app logs , and tries to restart the process by itself , sometimes it success to restart it ,it-self after a while and some time it can’t

here is a sample of pm2 logs of killing the app at 8:13 am and tries to restart it every 100ms but failed at the end

2022-07-28T08:13:34: PM2 log: Stopping app:sal-api id:0

2022-07-28T08:13:34: PM2 log: Stopping app:sal-user id:1

2022-07-28T08:13:34: PM2 log: pid=229164 msg=failed to kill - retrying in 100ms

2022-07-28T08:13:34: PM2 log: App [sal-api:0] exited with code [0] via signal [SIGINT]

2022-07-28T08:13:34: PM2 log: App [sal-user:1] exited with code [0] via signal [SIGINT]

2022-07-28T08:13:34: PM2 log: pid=229154 msg=process killed

2022-07-28T08:13:34: PM2 log: App [sal-api:0] starting in -fork mode-

2022-07-28T08:13:34: PM2 log: App [sal-api:0] online

2022-07-28T08:13:34: PM2 log: Stopping app:sal-admin id:2

2022-07-28T08:13:34: PM2 log: pid=229164 msg=process killed

2022-07-28T08:13:34: PM2 log: App [sal-user:1] starting in -fork mode-

2022-07-28T08:13:34: PM2 log: App [sal-user:1] online

2022-07-28T08:13:34: PM2 log: pid=229206 msg=failed to kill - retrying in 100ms

2022-07-28T08:13:34: PM2 log: pid=229206 msg=failed to kill - retrying in 100ms

2022-07-28T08:13:34: PM2 log: pid=229206 msg=failed to kill - retrying in 100ms

2022-07-28T08:13:34: PM2 log: pid=229206 msg=failed to kill - retrying in 100ms

2022-07-28T08:13:34: PM2 log: pid=229206 msg=failed to kill - retrying in 100ms

2022-07-28T08:13:34: PM2 log: pid=229206 msg=failed to kill - retrying in 100ms

2022-07-28T08:13:35: PM2 log: pid=229206 msg=failed to kill - retrying in 100ms

2022-07-28T08:13:35: PM2 log: pid=229206 msg=failed to kill - retrying in 100ms

2022-07-28T08:13:35: PM2 log: pid=229206 msg=failed to kill - retrying in 100ms

2022-07-28T08:13:35: PM2 log: pid=229206 msg=failed to kill - retrying in 100ms

2022-07-28T08:13:35: PM2 log: pid=229206 msg=failed to kill - retrying in 100ms

2022-07-28T08:13:35: PM2 log: pid=229206 msg=failed to kill - retrying in 100ms

2022-07-28T08:13:35: PM2 log: pid=229206 msg=failed to kill - retrying in 100ms

2022-07-28T08:13:35: PM2 log: pid=229206 msg=failed to kill - retrying in 100ms

2022-07-28T08:13:35: PM2 log: pid=229206 msg=failed to kill - retrying in 100ms

2022-07-28T08:13:35: PM2 log: Process with pid 229206 still alive after 1600ms, sending it SIGKILL now…

2022-07-28T08:13:35: PM2 log: App [sal-admin:2] exited with code [0] via signal [SIGKILL]

2022-07-28T08:13:36: PM2 log: pid=229206 msg=process killed


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
July 29, 2022

Hi @smartsway,

Check your other logs, I’ll assume PM2 might be killing the process due to another reason like high load/ your server being out of memory. Check the logs in /var/log, they might give you another hint.