Is there some sort of handler that I can run which will allow me to run some code right before the app is about to be shut down due to excessive CPU/RAM usage? I want to send myself an email alert (via rollbar, in my case) if my servers are being shut down by the hypervisor/host.
I only want to be informed if the shut down is specifically related to my app using too much compute.
I imagine the code to be something like this (semi-pseudo-code):
process.on('exit', function(e) {
if(e.reason == "excessive_compute_usage") rollbar.critical("Server shut down due to too much compute usage on glitch.");
});
Is there some way to detect this sort of shut down?
Thanks!