show how many nodes responded

v1.18.x
Barış Soner Uşaklı 8 years ago
parent 0b3656f34c
commit af6cde5534

@ -1,5 +1,6 @@
{ {
"you-are-on": "Info - You are on <strong>%1:%2</strong>", "you-are-on": "Info - You are on <strong>%1:%2</strong>",
"nodes-responded": "%1 nodes responded within %2ms!",
"host": "host", "host": "host",
"pid": "pid", "pid": "pid",
"nodejs": "nodejs", "nodejs": "nodejs",

@ -16,22 +16,30 @@ var info = {};
infoController.get = function (req, res) { infoController.get = function (req, res) {
info = {}; info = {};
pubsub.publish('sync:node:info:start'); pubsub.publish('sync:node:info:start');
var timeoutMS = 1000;
setTimeout(function () { setTimeout(function () {
var data = []; var data = [];
Object.keys(info).forEach(function (key) { Object.keys(info).forEach(function (key) {
data.push(info[key]); data.push(info[key]);
}); });
data.sort(function (a, b) { data.sort(function (a, b) {
if (a.os.hostname < b.os.hostname) { if (a.id < b.id) {
return -1; return -1;
} }
if (a.os.hostname > b.os.hostname) { if (a.id > b.id) {
return 1; return 1;
} }
return 0; return 0;
}); });
res.render('admin/development/info', { info: data, infoJSON: JSON.stringify(data, null, 4), host: os.hostname(), port: nconf.get('port') }); res.render('admin/development/info', {
}, 500); info: data,
infoJSON: JSON.stringify(data, null, 4),
host: os.hostname(),
port: nconf.get('port'),
nodeCount: data.length,
timeout: timeoutMS
});
}, timeoutMS);
}; };
pubsub.on('sync:node:info:start', function () { pubsub.on('sync:node:info:start', function () {
@ -39,7 +47,8 @@ pubsub.on('sync:node:info:start', function () {
if (err) { if (err) {
return winston.error(err); return winston.error(err);
} }
pubsub.publish('sync:node:info:end', { data: data, id: os.hostname() + ':' + nconf.get('port') }); data.id = os.hostname() + ':' + nconf.get('port');
pubsub.publish('sync:node:info:end', { data: data, id: data.id });
}); });
}); });

@ -5,6 +5,8 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
<span>[[admin/development/info:nodes-responded, {nodeCount}, {timeOut}]]</span>
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>

Loading…
Cancel
Save