From 9664033b73266ef35530611f135ddfa19ca204de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sun, 28 May 2017 18:40:32 -0400 Subject: [PATCH] add memory usage to info page --- .../en-GB/admin/development/info.json | 1 + src/controllers/admin/info.js | 34 ++++++++++--------- src/views/admin/development/info.tpl | 2 ++ 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/public/language/en-GB/admin/development/info.json b/public/language/en-GB/admin/development/info.json index 24bf179655..0a4ae6fe2c 100644 --- a/public/language/en-GB/admin/development/info.json +++ b/public/language/en-GB/admin/development/info.json @@ -6,6 +6,7 @@ "nodejs": "nodejs", "online": "online", "git": "git", + "memory": "memory", "load": "load", "uptime": "uptime", diff --git a/src/controllers/admin/info.js b/src/controllers/admin/info.js index 734d151a3d..92572840b9 100644 --- a/src/controllers/admin/info.js +++ b/src/controllers/admin/info.js @@ -9,7 +9,7 @@ var exec = require('child_process').exec; var pubsub = require('../../pubsub'); var rooms = require('../../socket.io/admin/rooms'); -var infoController = {}; +var infoController = module.exports; var info = {}; @@ -76,21 +76,25 @@ function getNodeInfo(callback) { }, }; - async.parallel({ - stats: function (next) { - rooms.getLocalStats(next); + data.process.memoryUsage.humanReadable = (data.process.memoryUsage.rss / (1024 * 1024)).toFixed(2); + + async.waterfall([ + function (next) { + async.parallel({ + stats: function (next) { + rooms.getLocalStats(next); + }, + gitInfo: function (next) { + getGitInfo(next); + }, + }, next); }, - gitInfo: function (next) { - getGitInfo(next); + function (results, next) { + data.git = results.gitInfo; + data.stats = results.stats; + next(null, data); }, - }, function (err, results) { - if (err) { - return callback(err); - } - data.git = results.gitInfo; - data.stats = results.stats; - callback(null, data); - }); + ], callback); } function getGitInfo(callback) { @@ -111,5 +115,3 @@ function getGitInfo(callback) { }, }, callback); } - -module.exports = infoController; diff --git a/src/views/admin/development/info.tpl b/src/views/admin/development/info.tpl index f594e7a499..d995233f17 100644 --- a/src/views/admin/development/info.tpl +++ b/src/views/admin/development/info.tpl @@ -15,6 +15,7 @@ [[admin/development/info:nodejs]] [[admin/development/info:online]] [[admin/development/info:git]] + [[admin/development/info:memory]] [[admin/development/info:load]] [[admin/development/info:uptime]] @@ -31,6 +32,7 @@ {info.stats.socketCount} {info.git.branch}@{info.git.hash} + {info.process.memoryUsage.humanReadable} mb {info.os.load} {info.process.uptime}