2
0
Fork 0
tcrud/lib/plugin/server/info/info-uptime.js

29 lines
664 B
JavaScript
Raw Permalink Normal View History

2017-06-10 14:53:29 +00:00
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
}
}
}));
};
};
})();