server.close() vs process.disconnect()


This Content is from Stack Overflow. Question asked by kjunz

I am currently using cluster in my node.js application but have a bit of confusion on gracefully exiting the server.

Previously I was using just a single process, so in the ‘uncaughtException‘ handler I call server.close(), which stops all incoming requests, then I also set up a timer for about 10 seconds, after that I call process.exit() to kill the server.

Now with cluster, each child process is created with an IPC channel, and calling process.disconnect() seems to do exactly the same thing as what I described for the single node process.

My question is, when using cluster and if I want to gracefully exit the service, what should I do? seems like process.disconnect() is good enough?


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?