cluster.disconnect([callback])


  • callback <Function> 当所有工作线程断开连接且句柄关闭时调用。

cluster.workers 中的每个工作线程调用 .disconnect()

🌐 Calls .disconnect() on each worker in cluster.workers.

当它们断开连接时,所有内部句柄将被关闭,如果没有其他事件在等待,主进程将能够优雅地结束。

🌐 When they are disconnected all internal handles will be closed, allowing the primary process to die gracefully if no other event is waiting.

该方法接受一个可选的回调参数,完成时会调用该回调。

🌐 The method takes an optional callback argument which will be called when finished.

这只能从主进程调用。

🌐 This can only be called from the primary process.