Javascript 倾听工人的方式';节点中Clustor模块中的s事件

Javascript 倾听工人的方式';节点中Clustor模块中的s事件,javascript,node.js,child-process,Javascript,Node.js,Child Process,我正在使用clustor模块进行多进程应用。我想听听Worker事件,文档中的示例如下: cluster.fork().on(‘listening’,cb); const http = require(‘http’); const cluster = require(‘cluster’); const worker = cluster.worker; http.createServer((req,res)=>{ res.writeHead(200); res.end(“hel

我正在使用clustor模块进行多进程应用。我想听听Worker事件,文档中的示例如下:

cluster.fork().on(‘listening’,cb);
const http = require(‘http’);
const cluster = require(‘cluster’);
const worker = cluster.worker;
http.createServer((req,res)=>{
   res.writeHead(200);
   res.end(“hello world”);
}).listen(8099);
worker.on(‘listening’,address=>{
  console.log(address:${address});
});
但是我想把worker和master分开,所以在我的worker.js文件中,我这样写:

cluster.fork().on(‘listening’,cb);
const http = require(‘http’);
const cluster = require(‘cluster’);
const worker = cluster.worker;
http.createServer((req,res)=>{
   res.writeHead(200);
   res.end(“hello world”);
}).listen(8099);
worker.on(‘listening’,address=>{
  console.log(address:${address});
});
但是监听回调不会运行,那么这是否意味着我只能监听master.js中的Worker事件