![](/img/trans.png)
[英]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.