From 352496124f98e064548ab67a0614f18fbf61cad4 Mon Sep 17 00:00:00 2001 From: Adhidarma Hadiwinoto <adhisimon@gmail.com> Date: Mon, 31 May 2021 16:34:21 +0700 Subject: [PATCH] matrix.start_time_from_now --- lib/apiserver/routers/matrix.js | 5 ++++- lib/matrix.js | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/apiserver/routers/matrix.js b/lib/apiserver/routers/matrix.js index 2f34fd9..c5ee875 100644 --- a/lib/apiserver/routers/matrix.js +++ b/lib/apiserver/routers/matrix.js @@ -1,4 +1,5 @@ const express = require('express'); +const moment = require('moment'); const os = require('os'); const matrix = require('../../matrix'); @@ -7,7 +8,9 @@ const router = express.Router(); module.exports = router; const pageIndex = (req, res) => { - matrix.uptime = process.uptime(); + matrix.ts = new Date(); + matrix.start_time_from_now = moment(matrix.start_time).fromNow(); + matrix.uptime_secs = process.uptime(); matrix.loadavg = os.loadavg(); matrix.workdir = process.cwd; matrix.memory_usage = process.memoryUsage(); diff --git a/lib/matrix.js b/lib/matrix.js index 3721775..2c07f6f 100644 --- a/lib/matrix.js +++ b/lib/matrix.js @@ -3,8 +3,10 @@ const os = require('os'); module.exports = { pid: process.pid, + ts: new Date(), start_time: new Date(), - uptime: process.uptime(), + start_time_from_now: null, + uptime_secs: process.uptime(), hostname: os.hostname(), loadavg: os.loadavg(), workdir: process.cwd(), -- 1.9.0