简单的问题:cluster.fork与child_process.fork的区别是什么
详情:
我可以将参数传递给cluster.fork
我可以通过child_process.fork在同一个端口或unixsock上监听ChildProcess
简单的问题:cluster.fork与child_process.fork的区别是什么
详情:
我可以将参数传递给cluster.fork
我可以通过child_process.fork在同一个端口或unixsock上监听ChildProcess
阅读文档: child_process.fork
VS cluster.fork
。
和...之间的不同
cluster.fork()
和child_process.fork()
只是该集群允许在工作人员之间共享TCP服务器。cluster.fork
是在...之上实现的child_process.fork
。
http://nodejs.org/api/cluster.html
1.我可以将参数传递给cluster.fork
不是根据文档,并且:
> var cluster = require('cluster')
undefined
> cluster
{ isWorker: false,
isMaster: true,
fork: [Function],
_startWorker: [Function],
_getServer: [Function] }
> cluster.fork.length
0
(一个 功能 length
是它的形式参数的数量)。使用 消息传递 代替。
2.我可以在child_process.fork创建的ChildProcess创建的同一端口或unixsock上监听
大概是的,因为 cluster.fork
是在...之上实现的 child_process.fork
。但是,有一个 原因 那 cluster.fork
已经存在,如果你想在同一个端口上侦听。