• Debian 11 is approaching its end-of-life (vendor EOL date - August 31, 2026). Plesk Obsidian 18.0.80 will be the last release to support it.
    If you are running Plesk Obsidian on Debian 11, we recommend you upgrade those servers to Debian 12 using our dist-upgrade tool.
  • We plan to deprecate and remove the support for XML RPC protocol versions earlier than 1.6.9.1 in Plesk Obsidian 18.0.82. We strongly recommend that you update all existing integrations using earlier versions of the XML RPC protocol to comply with the version 1.6.9.1 specification.

Question How do I get a graceful shutdown of Node.js?

Silent3

New Pleskian
I recently decided to add some text message notifications to a Node.js server app, for when a particular update was discovered. While I was at it, I figured it would be a good idea to add a server start-up and shutdown notifications too. This led to a few of unpleasant discoveries:

1) Roughly every 24 hours my server (not the entire Plesk server, just this one Node.js server app) was restarting for no good reason, between 3:30-4:30 AM.
2) There was no graceful detection of a shutdown before each restart, so it appears that the Node.js app was being killed outright, not sent SIGINT or SIGTERM, which I was listening for.
3) Even using the Plesk control panel, where you can request an app restart, a graceful restart doesn't occur. Your Node.js app is simply unceremoniously killed.

1629393588478.png

The once-per-24-hour restart, after some investigation, is apparently triggered by Apache log rotation. Why simple log rotation should cause this is another mystery to be solved.

In the meantime, I want to know if there's a way to make sure GRACEFUL shutdowns happen, whether they happen because Apache is stopping or shutting down, or because the "Restart App" button is pressed.

I look for shutdowns by monitoring these signals:

JavaScript:
process.on('SIGINT', shutdown);
process.on('SIGTERM', shutdown);
process.on('SIGUSR2', shutdown);

Is there a different signal I should check for?
Is the process shutdown mercilessly with a SIGKILL instead?
If so, can I change that, perhaps with some sort of delay to give a graceful shutdown some time to occur?
 
Contact Plesk Support Team if nobody on the forum can help you.
Unless there's a free support tier for that, that's not going to work for me. This is for a hobby project, not business. It's really annoying how I can find absolutely nothing documented online about how Node.js is implemented in Plesk.
 
Thanks for the help, but that's just the bog standard installation and user docs.

What I'd need to know to figure out what's going on is a lot more technical detail about how Node.js gets hooked into Apache and/or nginx. I need to know why my server doesn't pass SIGINT or SIGTERM signals along to Node applications, if and how I could change that, and what exactly is going on behind the scenes that makes my Plesk server pull the rug out from under Node.js at least once every 24 hours, so that everything has to start fresh again without having had a clean shut-down.
 
Back
Top