joyent/node — pull request #2740 by AndreasMadsen (2012-02-12 09:29:02+00:00)
Title: Cluster 2.0 - step 6 : Add disconnect methods to graceful shutdown

It is extremely 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()` run `worker.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 as `worker.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_