change in stat storage
parent
71dd0bfa04
commit
f99d294a1c
|
@ -48,6 +48,8 @@ let started = false;
|
||||||
let stopped = false;
|
let stopped = false;
|
||||||
|
|
||||||
exports.start = async () => {
|
exports.start = async () => {
|
||||||
|
let startDurations = {};
|
||||||
|
stats.gauge('startDurations', () => durations);
|
||||||
if (started) return express.server;
|
if (started) return express.server;
|
||||||
started = true;
|
started = true;
|
||||||
if (stopped) throw new Error('restart not supported');
|
if (stopped) throw new Error('restart not supported');
|
||||||
|
@ -62,35 +64,30 @@ exports.start = async () => {
|
||||||
|
|
||||||
// Performance stats gauges
|
// Performance stats gauges
|
||||||
// We use gauges because a reload might replace the value
|
// We use gauges because a reload might replace the value
|
||||||
stats.gauge('npmLoadDuration', () => npmLoadDuration);
|
|
||||||
const preNpmLoad = Date.now();
|
const preNpmLoad = Date.now();
|
||||||
await util.promisify(npm.load)();
|
await util.promisify(npm.load)();
|
||||||
const npmLoadDuration = Date.now() - preNpmLoad;
|
const startDurations.npmLoad = Date.now() - preNpmLoad;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
stats.gauge('dbInitDuration', () => dbInitDuration);
|
|
||||||
const preDbInit = Date.now();
|
const preDbInit = Date.now();
|
||||||
await db.init();
|
await db.init();
|
||||||
const dbInitDuration = Date.now() - preDbInit;
|
durations.dbInit = Date.now() - preDbInit;
|
||||||
|
|
||||||
stats.gauge('loadPluginsDuration', () => loadPluginsDuration);
|
|
||||||
const prePluginsUpdate = Date.now();
|
const prePluginsUpdate = Date.now();
|
||||||
await plugins.update();
|
await plugins.update();
|
||||||
const loadPluginsDuration = Date.now() - prePluginsUpdate;
|
durations.loadPlugins = Date.now() - prePluginsUpdate;
|
||||||
|
|
||||||
console.info(`Installed plugins: ${plugins.formatPluginsWithVersion()}`);
|
console.info(`Installed plugins: ${plugins.formatPluginsWithVersion()}`);
|
||||||
console.debug(`Installed parts:\n${plugins.formatParts()}`);
|
console.debug(`Installed parts:\n${plugins.formatParts()}`);
|
||||||
console.debug(`Installed hooks:\n${plugins.formatHooks()}`);
|
console.debug(`Installed hooks:\n${plugins.formatHooks()}`);
|
||||||
|
|
||||||
stats.gauge('loadSettingDuration', () => loadSettingsDuration);
|
|
||||||
const preLoadSettings = Date.now();
|
const preLoadSettings = Date.now();
|
||||||
await hooks.aCallAll('loadSettings', {settings});
|
await hooks.aCallAll('loadSettings', {settings});
|
||||||
const loadSettingsDuration = Date.now() - preLoadSettings;
|
durations.loadSettings = Date.now() - preLoadSettings;
|
||||||
|
|
||||||
stats.gauge('createSettingsDuration', () => createSettingsDuration);
|
|
||||||
const preCreateServer = Date.now();
|
const preCreateServer = Date.now();
|
||||||
await hooks.aCallAll('createServer');
|
await hooks.aCallAll('createServer');
|
||||||
const createSettingsDuration = Date.now() - preCreateServer;
|
durations.createSettings = Date.now() - preCreateServer;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`exception thrown: ${e.message}`);
|
console.error(`exception thrown: ${e.message}`);
|
||||||
if (e.stack) console.log(e.stack);
|
if (e.stack) console.log(e.stack);
|
||||||
|
|
Loading…
Reference in New Issue