29 lines
664 B
JavaScript
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
|
||
|
}
|
||
|
}
|
||
|
}));
|
||
|
};
|
||
|
};
|
||
|
})();
|