[英]What are the effective differences between child_process.fork and cluster.fork?
[英]What's the difference with childprocess.fork between cluster.fork
简单的问题:cluster.fork之间的child_process.fork有什么不同
详情:
我可以将参数传递给cluster.fork
我可以在child_process.fork上为ChildProcess创建的同一端口或unixsock上监听
阅读文档: 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
已存在的原因 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.