add uptime info
This commit is contained in:
parent
66758f4dbf
commit
b75552a287
|
@ -23,6 +23,8 @@ var recase = require('recase').create({});
|
||||||
var camelCopy = recase.camelCopy.bind(recase);
|
var camelCopy = recase.camelCopy.bind(recase);
|
||||||
var snakeCopy = recase.snakeCopy.bind(recase);
|
var snakeCopy = recase.snakeCopy.bind(recase);
|
||||||
var TPLS = TOML.parse(fs.readFileSync(path.join(__dirname, "../lib/en-us.toml"), 'utf8'));
|
var TPLS = TOML.parse(fs.readFileSync(path.join(__dirname, "../lib/en-us.toml"), 'utf8'));
|
||||||
|
var startTime = Date.now();
|
||||||
|
var connectTimes = [];
|
||||||
|
|
||||||
var TelebitRemote = require('../lib/daemon/index.js').TelebitRemote;
|
var TelebitRemote = require('../lib/daemon/index.js').TelebitRemote;
|
||||||
|
|
||||||
|
@ -586,6 +588,7 @@ function handleApi(req, res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatus() {
|
function getStatus() {
|
||||||
|
var now = Date.now();
|
||||||
res.setHeader('Content-Type', 'application/json');
|
res.setHeader('Content-Type', 'application/json');
|
||||||
res.end(JSON.stringify(
|
res.end(JSON.stringify(
|
||||||
{ module: 'status'
|
{ module: 'status'
|
||||||
|
@ -596,6 +599,10 @@ function handleApi(req, res) {
|
||||||
, connected: 'maybe (todo)'
|
, connected: 'maybe (todo)'
|
||||||
, version: pkg.version
|
, version: pkg.version
|
||||||
, servernames: state.servernames
|
, servernames: state.servernames
|
||||||
|
, proctime: Math.round(process.uptime() * 1000)
|
||||||
|
, uptime: now - startTime
|
||||||
|
, runtime: connectTimes.length && (now - connectTimes[0]) || 0
|
||||||
|
, reconnects: connectTimes.length
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -995,6 +1002,7 @@ function rawStartTelebitRemote(keepAlive) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onConnect() {
|
function onConnect() {
|
||||||
|
connectTimes.unshift(Date.now());
|
||||||
console.info('[connect] relay established');
|
console.info('[connect] relay established');
|
||||||
myRemote.removeListener('error', onConnectError);
|
myRemote.removeListener('error', onConnectError);
|
||||||
myRemote.once('error', function (err) {
|
myRemote.once('error', function (err) {
|
||||||
|
|
Loading…
Reference in New Issue