Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

在egg中启动自定义cluster失败

$
0
0

尝试在egg中使用自定义启动一组自己写的cluster, 但是却启动不了,cluster的变量也很奇怪,请教一下各位大神

// 自定义启动 app.js
module.exports = app => {
  app.beforeStart(async () => {
    app.cluster = require('./cluster/master');
  });
};
// ./cluster/master.js
const cluster = require('cluster');
console.log('NODE_UNIQUE_ID' in process.env); // false
console.log(cluster.isMaster); //false
...
module.exports = cluster;

最奇怪的就是从app.js 调用执行master.js 后,尽管NODE_UNIQUE_ID是undefined,但cluster.isMaster却是false???实在想不通。因为isMaster是false, 后面的setupMaster()等操作也无法进行。


Viewing all articles
Browse latest Browse all 14821

Trending Articles