Node.js based forum software built for the modern web
feat: human readable uptime
Barış Soner Uşaklı672d4da078d2
diff --git a/src/controllers/admin/info.js b/src/controllers/admin/info.jsindex 36dec3a0ef..9919deb8cc 100644--- a/src/controllers/admin/info.js+++ b/src/controllers/admin/info.js@@ -93,6 +93,7 @@ async function getNodeInfo() {data.process.cpuUsage.system /= 1000000;data.process.cpuUsage.system = data.process.cpuUsage.system.toFixed(2);data.process.memoryUsage.humanReadable = (data.process.memoryUsage.rss / (1024 * 1024)).toFixed(2);+ data.process.uptimeHumanReadable = humanReadableUptime(data.process.uptime);data.os.freemem = (data.os.freemem / 1000000).toFixed(2);data.os.totalmem = (data.os.totalmem / 1000000).toFixed(2);const [stats, gitInfo] = await Promise.all([@@ -104,6 +105,17 @@ async function getNodeInfo() {return data;}+function humanReadableUptime(seconds) {+ if (seconds < 60) {+ return Math.floor(seconds) + 's';+ } else if (seconds < 3600) {+ return Math.floor(seconds / 60) + 'm';+ } else if (seconds < 3600 * 24) {+ return Math.floor(seconds / (60 * 60)) + 'h';+ }+ return Math.floor(seconds / (60 * 60 * 24)) + 'd';+}+async function getGitInfo() {function get(cmd, callback) {exec(cmd, function (err, stdout) {diff --git a/src/views/admin/development/info.tpl b/src/views/admin/development/info.tplindex 5d4df86bd5..604e13bfb7 100644--- a/src/views/admin/development/info.tpl+++ b/src/views/admin/development/info.tpl@@ -41,7 +41,7 @@<td>{info.process.cpuUsage.user} / {info.process.cpuUsage.system}</td><td>{info.process.memoryUsage.humanReadable} mb / {info.os.freemem} mb</td><td>{info.os.load}</td>- <td>{info.process.uptime}</td>+ <td>{info.process.uptimeHumanReadable}</td></tr><!-- END info --></tbody>