我已经阅读了这个问题的答案,并尝试了很多方法来解决我的问题,但无法解决 - 因此从我这边发布了这个查询。
基本上我有一个数组中的服务列表 - 在我的 NodeJS 应用程序运行的不同盒子上运行的数字约为 1500。根据我的代码,我 ssh 到 /a 框并通过期望脚本,然后 cd 到特定目录以获取每个服务版本/构建 ID,该 ID 存储在每个服务的特定单独路径的特定文件中。对于某些服务,相同的文件(具有版本/构建信息)可能存储在框中的不同位置。所以我在应用程序中有一个算法,如果尝试获取第一个路径的详细信息失败,我将使用其他脚本在不同的路径中查找信息:
主要代码块:
exports.getservicedetails = function(box,res) {
var job = [];
for (i = 0; i < services.length; i++ )
{
var children = new Object();
children.server = services[i];
children.box = box;
children.process = spawn('./scripts/info.sh', [children.server , children.box , getStageURL(children.box)]);
children.runstate = 1;
job.push(children);
createChildEvents(job, i, res);
}
}
现在我为每个生成的任务设置所有事件:
function createChildEvents(child, id, res){
(child[id]).process.stderr.on('data', function (data) {
(child[id]).runstate = 0;
});
(child[i]).process.on('exit', function (code) {
(child[id]).runstate = 0;
checkstate(child, res); // function to check if all spawned tasks has exited
});
(child[id]).process.stdout.on('data', function (data) {
var result = data.toString().split("\r\n"); // split the stdout outputted lines
for (var i = 0; i < result.length; i++)
{
console.log('Server : ' + (child[id]).server + " PID : " + (child[id]).process.pid + ' ' + (child[id]).box);
if ((child[id]).box.length > 0 && result[i].match(/No such file or directory/gi) != null) {
(child[id]).process = spawn('./scripts/info2.sh ',[(child[id]).server, (child[id]).box, getStageURL((child[id]).box)]);
(child[id]).box = '';
(child[id]).runstate = 1;
createChildEvents(child, id, res);
break;
}
if(result[i].match(/release_version*/) != null || result[i].match(/app.version*/) != null)
(child[id]).serversion = (result[i].split('='))[1];
if(result[i].match(/release_number*/) != null || result[i].match(/app.id*/) != null)
(child[id]).serproduct = (result[i].split('='))[1];
}
});
}
问题是,在获得如下所述的第 11 个控制台日志后,我看到了错误:
Server : a PID : 27200 myboxname
Server : b PID : 31650 myboxname
Server : d PID : 31644 myboxname
Server : e PID : 31664 myboxname
Server : f PID : 28946 myboxname
Server : g PID : 32507 myboxname
Server : h PID : 29329 myboxname
Server : i PID : 29905 myboxname
Server : j PID : 29883 myboxname
Server : k PID : 481 myboxname
Server : l PID : 777 myboxname
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at EventEmitter.addListener (events.js:168:15)
at EventEmitter.once (events.js:189:8)
at Transport.logException (src/node_modules/winston/lib/winston/transports/transport.js:118:8)
at logAndWait (src/node_modules/winston/lib/winston/logger.js:613:15)
at async.forEach (src/node_modules/winston/node_modules/async/lib/async.js:86:13)
at Array.forEach (native)
at _forEach (src/node_modules/winston/node_modules/async/lib/async.js:26:24)
at Object.async.forEach (src/node_modules/winston/node_modules/async/lib/async.js:85:9)
at Logger._uncaughtException (src/node_modules/winston/lib/winston/logger.js:636:9)
at process.EventEmitter.emit (events.js:115:20)
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at EventEmitter.addListener (events.js:168:15)
at EventEmitter.once (events.js:189:8)
at Transport.logException (src/node_modules/winston/lib/winston/transports/transport.js:117:8)
at logAndWait (src/node_modules/winston/lib/winston/logger.js:613:15)
at async.forEach (src/node_modules/winston/node_modules/async/lib/async.js:86:13)
at Array.forEach (native)
at _forEach (src/node_modules/winston/node_modules/async/lib/async.js:26:24)
at Object.async.forEach (src/node_modules/winston/node_modules/async/lib/async.js:85:9)
at Logger._uncaughtException (src/node_modules/winston/lib/winston/logger.js:636:9)
at process.EventEmitter.emit (events.js:115:20)
我尝试添加 'process.setMaxListeners(0);' 在我的代码中的很多地方,但我仍然看到这个错误?
知道如何解决这个问题吗?提前致谢。