-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Close client connections on SIGINT/SIGTERM #2964
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
Conversation
000e7aa
to
f14c8ab
Compare
@kulshekhar updated the pull request - view changes |
1 similar comment
@kulshekhar updated the pull request - view changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small nit but that should do.
Could you add the link to the node-js issue around for posterity
@@ -43,8 +47,27 @@ function startServer(options, callback) { | |||
} | |||
ParseServer.createLiveQueryServer(liveQueryServer, options.liveQueryServerOptions); | |||
} | |||
|
|||
function initializeConnections(socket) { | |||
const socketId = socket.remoteAddress + ':' + socket.remotePort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add trailing:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this?
function initializeConnections(socket) {
/* Currently, express doesn't shut down immediately after receiving SIGINT/SIGTERM if it has client connections that haven't timed out. (This is a known issue with node - https://github.com/nodejs/node/issues/2642)
This intends to fix this behavior such that parse server will close all open connections and initiate the shutdown process as soon as it receives a SIGINT/SIGTERM signal. */
const socketId = socket.remoteAddress + ':' + socket.remotePort;
@kulshekhar updated the pull request - view changes |
Awesome! |
@flovilmart I integrated a job scheduler in the same server that Parse server use, I am using Kue-Scheduler. In order to prevent stuck jobs with Kue I had my own code that detect when there is SIGINT/SIGTERM and does a clean shutdown of Kue (radis based connection) by calling - Queue.shutdown( shutDownTimout, function(err){ Now Parse handing of SIGINT/SIGTERM is independent of Kue handling of shutdown and one can decided to exist earlier before the other. It will be very helpful if there was some hook (function) that Parse server will before it actually call process.exit() and allow other connections to close cleanly before Parse call exit(). |
Fixes #2875
Currently, express doesn't shut down immediately after receiving SIGINT/SIGTERM if it has client connections that haven't timed out. (This is a known issue with node)
This PR intends to fix this behavior such that parse server will close all open connections and initiate the shutdown process as soon as it receives a SIGINT/SIGTERM signal.