mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-24 01:16:15 -04:00
express: Change httpUptime
to httpStartTime
(#4777)
It's better to provide a primitive value and let the consumer of the metric do math if desired. Co-authored-by: John McLear <john@mclear.co.uk>
This commit is contained in:
parent
13a0b0688f
commit
e674d9789e
3 changed files with 14 additions and 12 deletions
|
@ -30,9 +30,11 @@
|
||||||
* You can now generate a link to a specific line number in a pad. Appending
|
* You can now generate a link to a specific line number in a pad. Appending
|
||||||
`#L10` to a pad URL will cause your browser to scroll down to line 10.
|
`#L10` to a pad URL will cause your browser to scroll down to line 10.
|
||||||
* Database performance is significantly improved.
|
* Database performance is significantly improved.
|
||||||
* Browser caching improvements.
|
* Admin UI now has test coverage in CI. (The tests are not enabled by default;
|
||||||
* New stats/metrics: `activePads`, `httpUptime`, `lastDisconnected`,
|
see `settings.json`.)
|
||||||
|
* New stats/metrics: `activePads`, `httpStartTime`, `lastDisconnected`,
|
||||||
`memoryUsageHeap`.
|
`memoryUsageHeap`.
|
||||||
|
* Browser caching improvements.
|
||||||
* Users can now pick absolute white (`#fff`) as their color.
|
* Users can now pick absolute white (`#fff`) as their color.
|
||||||
* The `settings.json` template used for Docker images has new variables for
|
* The `settings.json` template used for Docker images has new variables for
|
||||||
controlling rate limiting.
|
controlling rate limiting.
|
||||||
|
|
|
@ -17,7 +17,7 @@ const logger = log4js.getLogger('http');
|
||||||
let serverName;
|
let serverName;
|
||||||
const sockets = new Set();
|
const sockets = new Set();
|
||||||
const socketsEvents = new events.EventEmitter();
|
const socketsEvents = new events.EventEmitter();
|
||||||
let startTime = null;
|
const startTime = stats.settableGauge('httpStartTime');
|
||||||
|
|
||||||
exports.server = null;
|
exports.server = null;
|
||||||
|
|
||||||
|
@ -46,11 +46,11 @@ const closeServer = async () => {
|
||||||
await p;
|
await p;
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
exports.server = null;
|
exports.server = null;
|
||||||
|
startTime.setValue(0);
|
||||||
logger.info('HTTP server closed');
|
logger.info('HTTP server closed');
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.createServer = 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');
|
console.log('Report bugs at https://github.com/ether/etherpad-lite/issues');
|
||||||
|
|
||||||
serverName = `Etherpad ${settings.getGitCommit()} (https://etherpad.org)`;
|
serverName = `Etherpad ${settings.getGitCommit()} (https://etherpad.org)`;
|
||||||
|
@ -217,7 +217,7 @@ exports.restartServer = async () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
await util.promisify(exports.server.listen).bind(exports.server)(settings.port, settings.ip);
|
await util.promisify(exports.server.listen).bind(exports.server)(settings.port, settings.ip);
|
||||||
startTime = new Date();
|
startTime.setValue(Date.now());
|
||||||
logger.info('HTTP server listening for connections');
|
logger.info('HTTP server listening for connections');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -56,28 +56,28 @@ describe('Admin > Settings', function () {
|
||||||
|
|
||||||
it('restart works', async function () {
|
it('restart works', async function () {
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
const getUptime = async () => {
|
const getStartTime = async () => {
|
||||||
try {
|
try {
|
||||||
const {httpUptime} = await $.ajax({
|
const {httpStartTime} = await $.ajax({
|
||||||
url: new URL('/stats', window.location.href),
|
url: new URL('/stats', window.location.href),
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
timeout: 450, // Slightly less than the waitForPromise() interval.
|
timeout: 450, // Slightly less than the waitForPromise() interval.
|
||||||
});
|
});
|
||||||
return httpUptime;
|
return httpStartTime;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
await helper.waitForPromise(async () => {
|
await helper.waitForPromise(async () => {
|
||||||
const uptime = await getUptime();
|
const startTime = await getStartTime();
|
||||||
return uptime != null && uptime > 0;
|
return startTime != null && startTime > 0 && Date.now() > startTime;
|
||||||
}, 1000, 500);
|
}, 1000, 500);
|
||||||
const clickTime = Date.now();
|
const clickTime = Date.now();
|
||||||
helper.admin$('#restartEtherpad').click();
|
helper.admin$('#restartEtherpad').click();
|
||||||
await helper.waitForPromise(async () => {
|
await helper.waitForPromise(async () => {
|
||||||
const uptime = await getUptime();
|
const startTime = await getStartTime();
|
||||||
return uptime != null && Date.now() - uptime >= clickTime;
|
return startTime != null && startTime >= clickTime;
|
||||||
}, 60000, 500);
|
}, 60000, 500);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue