mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-01 23:37:43 +03:00
Added theme-service-init
metric during boot
refs https://github.com/TryGhost/Toolbox/issues/254 - it's useful for us to know how long it takes the theme service to init, especially as it is dealing with a lot of user-provided files outside of the Ghost codebase
This commit is contained in:
parent
6bd1806650
commit
d0497a6e40
23
core/boot.js
23
core/boot.js
@ -25,9 +25,18 @@ class BootLogger {
|
||||
let {logging, startTime} = this;
|
||||
logging.info(`Ghost ${message} in ${(Date.now() - startTime) / 1000}s`);
|
||||
}
|
||||
metric(name) {
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {number} [initialTime]
|
||||
*/
|
||||
metric(name, initialTime) {
|
||||
let {metrics, startTime} = this;
|
||||
metrics.metric(name, Date.now() - startTime);
|
||||
|
||||
if (!initialTime) {
|
||||
initialTime = startTime;
|
||||
}
|
||||
|
||||
metrics.metric(name, Date.now() - initialTime);
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,8 +135,11 @@ async function initCore({ghostServer, config, bootLogger, frontend}) {
|
||||
|
||||
/**
|
||||
* These are services required by Ghost's frontend.
|
||||
* @param {object} options
|
||||
* @param {object} options.bootLogger
|
||||
|
||||
*/
|
||||
async function initServicesForFrontend() {
|
||||
async function initServicesForFrontend({bootLogger}) {
|
||||
debug('Begin: initServicesForFrontend');
|
||||
|
||||
debug('Begin: Routing Settings');
|
||||
@ -144,8 +156,11 @@ async function initServicesForFrontend() {
|
||||
// customThemSettingsService.api must be initialized before any theme activation occurs
|
||||
const customThemeSettingsService = require('./server/services/custom-theme-settings');
|
||||
customThemeSettingsService.init();
|
||||
|
||||
const themeService = require('./server/services/themes');
|
||||
const themeServiceStart = Date.now();
|
||||
await themeService.init();
|
||||
bootLogger.metric('theme-service-init', themeServiceStart);
|
||||
debug('End: Themes');
|
||||
|
||||
debug('Begin: Offers');
|
||||
@ -401,7 +416,7 @@ async function bootGhost({backend = true, frontend = true, server = true} = {})
|
||||
// Step 4 - Load Ghost with all its services
|
||||
debug('Begin: Load Ghost Services & Apps');
|
||||
await initCore({ghostServer, config, bootLogger, frontend});
|
||||
await initServicesForFrontend();
|
||||
await initServicesForFrontend({bootLogger});
|
||||
|
||||
if (frontend) {
|
||||
await initFrontend();
|
||||
|
Loading…
Reference in New Issue
Block a user