diff --git a/CHANGELOG.md b/CHANGELOG.md index cac510eeb..d29419353 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,8 @@ * Database performance is significantly improved. * Admin UI now has test coverage in CI. (The tests are not enabled by default; see `settings.json`.) -* New stats: `activePads`, `lastDisconnected`, `memoryUsageHeap`. +* New stats/metrics: `activePads`, `httpUptime`, `lastDisconnected`, + `memoryUsageHeap`. * For plugin authors: * New `callAllSerial()` function that invokes hook functions like `callAll()` except it supports asynchronous hook functions. diff --git a/src/node/hooks/express.js b/src/node/hooks/express.js index 86055bf25..36bf2e695 100644 --- a/src/node/hooks/express.js +++ b/src/node/hooks/express.js @@ -17,6 +17,7 @@ const logger = log4js.getLogger('http'); let serverName; const sockets = new Set(); const socketsEvents = new events.EventEmitter(); +let startTime = null; exports.server = null; @@ -49,6 +50,7 @@ const closeServer = async () => { }; exports.createServer = async () => { + stats.gauge('httpUptime', () => startTime == null ? 0 : new Date() - startTime); console.log('Report bugs at https://github.com/ether/etherpad-lite/issues'); serverName = `Etherpad ${settings.getGitCommit()} (https://etherpad.org)`; @@ -215,6 +217,8 @@ exports.restartServer = async () => { }); }); await util.promisify(exports.server.listen).bind(exports.server)(settings.port, settings.ip); + startTime = new Date(); + logger.info('HTTP server listening for connections'); }; exports.shutdown = async (hookName, context) => {