Cluster 2.0 - step 6 : Add disconnect methods to graceful shutdown#2740
Cluster 2.0 - step 6 : Add disconnect methods to graceful shutdown#2740AndreasMadsen wants to merge 1 commit intonodejs:masterfrom
Conversation
|
I'm afraide this this need a better testcase. |
|
@isaacs this is ready for review and thoughts |
|
Another approach to However Somehow I needed to write this message too conclude that |
|
@isaacs I have now rebased onto master and resolved all conflicts, the commits has also been squashed. |
This patch add a worker.disconnect() method there will stop the worker from accepting new connections and then stop the IPC. This allow the worker to die graceful. When the IPC has been disconnected a 'disconnect' event will emit. The patch also add a cluster.disconnect() method, this will call worker.disconnect() on all connected workers. When the workers are disconneted it will then close all server handlers. This allow the cluster itself to self terminate in a graceful way.
|
Landed on master. Thanks! |
It is important that a worker can die graceful so no connected clients are interrupted. This patch adds:
worker.disconnect()stop server from accepting new connections, and close the IPC channel when all connection are ended. The documentation include an example on how to make a timeout.cluster.disconnect()runworker.disconnect()and all living workers and then close the handlers create in master allowing the cluster to die graceful.worker.on('disconnect')emits when IPC channel is closed.cluster.on('disconnect')same asworker.on('disconnect')just global this follow the existing pattern.There was an related issue to this: #2088
This is about the merging in the good parts from the
cluster 2.0( see #2038 ) pull request