mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
stats: gather startup stats
This commit is contained in:
parent
cc7f11560f
commit
354a27970e
3 changed files with 28 additions and 0 deletions
|
@ -181,9 +181,16 @@ exports.restartServer = async () => {
|
||||||
app.use(exports.sessionMiddleware);
|
app.use(exports.sessionMiddleware);
|
||||||
|
|
||||||
app.use(cookieParser(settings.sessionKey, {}));
|
app.use(cookieParser(settings.sessionKey, {}));
|
||||||
|
const expressHooksDurations = {};
|
||||||
|
stats.gauge('expressHooksDurations', () => expressHooksDurations);
|
||||||
|
|
||||||
|
const preExpressConfigure = Date.now();
|
||||||
hooks.callAll('expressConfigure', {app});
|
hooks.callAll('expressConfigure', {app});
|
||||||
|
expressHooksDurations.configure = Date.now() - preExpressConfigure;
|
||||||
|
|
||||||
|
const preExpressCreateServer = Date.now();
|
||||||
hooks.callAll('expressCreateServer', {app, server: exports.server});
|
hooks.callAll('expressCreateServer', {app, server: exports.server});
|
||||||
|
expressHooksDurations.createServer = Date.now() - preExpressCreateServer;
|
||||||
|
|
||||||
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);
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,8 +5,12 @@ const plugins = require('../../../static/js/pluginfw/plugin_defs');
|
||||||
const CachingMiddleware = require('../../utils/caching_middleware');
|
const CachingMiddleware = require('../../utils/caching_middleware');
|
||||||
const Yajsml = require('etherpad-yajsml');
|
const Yajsml = require('etherpad-yajsml');
|
||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
|
const stats = require('../../stats');
|
||||||
|
|
||||||
exports.expressCreateServer = (hookName, args, cb) => {
|
exports.expressCreateServer = (hookName, args, cb) => {
|
||||||
|
const expressDurations = {};
|
||||||
|
stats.gauge('expressDurations', () => expressDurations);
|
||||||
|
const preMinification = Date.now();
|
||||||
// Cache both minified and static.
|
// Cache both minified and static.
|
||||||
const assetCache = new CachingMiddleware();
|
const assetCache = new CachingMiddleware();
|
||||||
args.app.all(/\/javascripts\/(.*)/, assetCache.handle);
|
args.app.all(/\/javascripts\/(.*)/, assetCache.handle);
|
||||||
|
@ -15,6 +19,9 @@ exports.expressCreateServer = (hookName, args, cb) => {
|
||||||
// file-specific hacks for ace/require-kernel/etc.
|
// file-specific hacks for ace/require-kernel/etc.
|
||||||
args.app.all('/static/:filename(*)', minify.minify);
|
args.app.all('/static/:filename(*)', minify.minify);
|
||||||
|
|
||||||
|
expressDurations.minification = Date.now() - preMinification;
|
||||||
|
const preYajsml = Date.now();
|
||||||
|
|
||||||
// Setup middleware that will package JavaScript files served by minify for
|
// Setup middleware that will package JavaScript files served by minify for
|
||||||
// CommonJS loader on the client-side.
|
// CommonJS loader on the client-side.
|
||||||
// Hostname "invalid.invalid" is a dummy value to allow parsing as a URI.
|
// Hostname "invalid.invalid" is a dummy value to allow parsing as a URI.
|
||||||
|
@ -33,6 +40,7 @@ exports.expressCreateServer = (hookName, args, cb) => {
|
||||||
jsServer.setAssociator(associator);
|
jsServer.setAssociator(associator);
|
||||||
|
|
||||||
args.app.use(jsServer.handle.bind(jsServer));
|
args.app.use(jsServer.handle.bind(jsServer));
|
||||||
|
expressDurations.yajsml = Date.now() - preYajsml;
|
||||||
|
|
||||||
// serve plugin definitions
|
// serve plugin definitions
|
||||||
// not very static, but served here so that client can do
|
// not very static, but served here so that client can do
|
||||||
|
|
|
@ -108,6 +108,8 @@ exports.start = async () => {
|
||||||
|
|
||||||
// start up stats counting system
|
// start up stats counting system
|
||||||
const stats = require('./stats');
|
const stats = require('./stats');
|
||||||
|
const startDurations = {};
|
||||||
|
stats.gauge('startDurations', () => startDurations);
|
||||||
stats.gauge('memoryUsage', () => process.memoryUsage().rss);
|
stats.gauge('memoryUsage', () => process.memoryUsage().rss);
|
||||||
stats.gauge('memoryUsageHeap', () => process.memoryUsage().heapUsed);
|
stats.gauge('memoryUsageHeap', () => process.memoryUsage().heapUsed);
|
||||||
|
|
||||||
|
@ -132,9 +134,18 @@ exports.start = async () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const preNpmLoad = Date.now();
|
||||||
await util.promisify(npm.load)();
|
await util.promisify(npm.load)();
|
||||||
|
startDurations.npmLoad = Date.now() - preNpmLoad;
|
||||||
|
|
||||||
|
const preDbInit = Date.now();
|
||||||
await db.init();
|
await db.init();
|
||||||
|
startDurations.dbInit = Date.now() - preDbInit;
|
||||||
|
|
||||||
|
const prePluginsUpdate = Date.now();
|
||||||
await plugins.update();
|
await plugins.update();
|
||||||
|
startDurations.loadPlugins = Date.now() - prePluginsUpdate;
|
||||||
|
|
||||||
const installedPlugins = Object.values(pluginDefs.plugins)
|
const installedPlugins = Object.values(pluginDefs.plugins)
|
||||||
.filter((plugin) => plugin.package.name !== 'ep_etherpad-lite')
|
.filter((plugin) => plugin.package.name !== 'ep_etherpad-lite')
|
||||||
.map((plugin) => `${plugin.package.name}@${plugin.package.version}`)
|
.map((plugin) => `${plugin.package.name}@${plugin.package.version}`)
|
||||||
|
@ -142,7 +153,9 @@ exports.start = async () => {
|
||||||
logger.info(`Installed plugins: ${installedPlugins}`);
|
logger.info(`Installed plugins: ${installedPlugins}`);
|
||||||
logger.debug(`Installed parts:\n${plugins.formatParts()}`);
|
logger.debug(`Installed parts:\n${plugins.formatParts()}`);
|
||||||
logger.debug(`Installed hooks:\n${plugins.formatHooks()}`);
|
logger.debug(`Installed hooks:\n${plugins.formatHooks()}`);
|
||||||
|
const preLoadSettings = Date.now();
|
||||||
await hooks.aCallAll('loadSettings', {settings});
|
await hooks.aCallAll('loadSettings', {settings});
|
||||||
|
startDurations.loadSettings = Date.now() - preLoadSettings;
|
||||||
await hooks.aCallAll('createServer');
|
await hooks.aCallAll('createServer');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('Error occurred while starting Etherpad');
|
logger.error('Error occurred while starting Etherpad');
|
||||||
|
|
Loading…
Reference in a new issue