2
0
Fork 0
tcrud/lib/plugin/server/info/info-uptime.js
2017-06-10 16:53:29 +02:00

29 lines
664 B
JavaScript

module.exports = (function () {
var timeBoot = new Date().getTime();
return function ServerInfoUptimePlugin() {
this.configPlugin = function (ctx) {
ctx.key='serverInfoUptime';
ctx.description='Makes the server uptime info public as json';
ctx.localDir = __dirname;
ctx.localConfigTemplate = 'info-uptime.json';
};
this.configServer = function(ctx) {
ctx.server.get(ctx.createSlugApiServerBase(),ctx.renderFunctionJSON(function () {
var timeNow = new Date().getTime();
return {
serverInfoUptime: {
time_boot: timeBoot,
time_now: timeNow,
uptime: timeNow-timeBoot
}
}
}));
};
};
})();