In my Node.js application I am calling an external API which takes more than 7 minutes to get the response, in the meantime I am getting this:
PM2 log : App [server:0] exited with code [0] via signal [SIGKILL]
and the process is getting killed.
In my Node.js application I am calling an external API which takes more than 7 minutes to get the response, in the meantime I am getting this:
PM2 log : App [server:0] exited with code [0] via signal [SIGKILL]
and the process is getting killed.
This fixed my problem.
First Stop & Delete your current running PM2 App.
pm2 stop <app name>
pm2 delete <app name>
Then execute the below commands:
pm2 kill
rm -rf ~/.pm2
Now start your app again and see the logs.
pm2 start <app name>
pm2 logs
Just had this happen to me too. The key was SIGKILL, which meant something was killing the process intentionally.
Looking in dmesg
I could see that the Linux OOM (out-of-memory) handler was terminating the process, which it was doing because the process had briefly exceeded the amount of memory I had allocated to the Docker container it was running inside.
In this case, increasing the available memory the process was permitted to use fixed the problem.
Usually in web waiting even one minute is already kind of signal. Chrome standard timeout is 3 minutes, so I think you should definitely check if your server not throwing timeout error on your request to external API.
Also good practice of server writing is to make it never crash on error, always wrap everything with try catch, use validations to catch errors and send back some prepared response, or in worst case just output error in server console, but still make server available to provess other requests after this.
PM2 is daemont but it is helpful only if your server crash sometimes and need to be up, if it crashes regually pm2 has no use, you need to fix your server.
Come to think of it, also check if that request taking too much resources to process, if system get out of resources it will kill your process.
© 2022 - 2024 — McMap. All rights reserved.