mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-28 09:31:17 +01:00
show how many nodes responded
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"you-are-on": "Info - You are on <strong>%1:%2</strong>",
|
||||
"nodes-responded": "%1 nodes responded within %2ms!",
|
||||
"host": "host",
|
||||
"pid": "pid",
|
||||
"nodejs": "nodejs",
|
||||
|
||||
@@ -16,22 +16,30 @@ var info = {};
|
||||
infoController.get = function (req, res) {
|
||||
info = {};
|
||||
pubsub.publish('sync:node:info:start');
|
||||
var timeoutMS = 1000;
|
||||
setTimeout(function () {
|
||||
var data = [];
|
||||
Object.keys(info).forEach(function (key) {
|
||||
data.push(info[key]);
|
||||
});
|
||||
data.sort(function (a, b) {
|
||||
if (a.os.hostname < b.os.hostname) {
|
||||
if (a.id < b.id) {
|
||||
return -1;
|
||||
}
|
||||
if (a.os.hostname > b.os.hostname) {
|
||||
if (a.id > b.id) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
res.render('admin/development/info', { info: data, infoJSON: JSON.stringify(data, null, 4), host: os.hostname(), port: nconf.get('port') });
|
||||
}, 500);
|
||||
res.render('admin/development/info', {
|
||||
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 () {
|
||||
@@ -39,7 +47,8 @@ pubsub.on('sync:node:info:start', function () {
|
||||
if (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 class="panel-body">
|
||||
<span>[[admin/development/info:nodes-responded, {nodeCount}, {timeOut}]]</span>
|
||||
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
Reference in New Issue
Block a user