log and show last restart on ACP dashboard

This commit is contained in:
Barış Soner Uşaklı
2018-05-02 13:38:15 -04:00
parent 2551df80f7
commit 1f8b000530
4 changed files with 46 additions and 10 deletions

View File

@@ -9,6 +9,8 @@ var versions = require('../../admin/versions');
var db = require('../../database');
var meta = require('../../meta');
var plugins = require('../../plugins');
var user = require('../../user');
var utils = require('../../utils');
var dashboardController = module.exports;
@@ -51,6 +53,9 @@ dashboardController.get = function (req, res, next) {
next(null, err ? null : result);
});
},
lastrestart: function (next) {
getLastRestart(next);
},
}, next);
},
function (results) {
@@ -65,6 +70,7 @@ dashboardController.get = function (req, res, next) {
notices: results.notices,
stats: results.stats,
canRestart: !!process.send,
lastrestart: results.lastrestart,
});
},
], next);
@@ -128,3 +134,24 @@ function getGlobalField(field, callback) {
callback(err, parseInt(count, 10) || 0);
});
}
function getLastRestart(callback) {
var lastrestart;
async.waterfall([
function (next) {
db.getObject('lastrestart', next);
},
function (_lastrestart, next) {
lastrestart = _lastrestart;
if (!lastrestart) {
return callback();
}
user.getUserData(lastrestart.uid, next);
},
function (userData, next) {
lastrestart.user = userData;
lastrestart.timestampISO = utils.toISOString(lastrestart.timestamp);
next(null, lastrestart);
},
], callback);
}