From 9a8b18a473486a512ff918d22cf7140e27ff3c12 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Tue, 16 Nov 2021 14:44:14 +0000 Subject: [PATCH] Swapped boot order for version util - The version util is now required in logging as well as sentry and migrations - I can see us needing it in config too, so put it straight to the first item - we do this so that the debug statements can tell us how long each step took as we look to optimise everything --- core/boot.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core/boot.js b/core/boot.js index 45450877e0..bad2c82f0a 100644 --- a/core/boot.js +++ b/core/boot.js @@ -68,6 +68,7 @@ async function initDatabase({config, logging}) { * @param {object} options * @param {object} options.ghostServer * @param {object} options.config + * @param {object} options.bootLogger */ async function initCore({ghostServer, config, bootLogger}) { debug('Begin: initCore'); @@ -311,12 +312,18 @@ async function bootGhost() { // These require their own try-catch block and error format, because we can't log an error if logging isn't working try { // Step 0 - Load config and logging - fundamental required components - // Config must be the first thing we do, because it is required for absolutely everything + // Version is required by logging, sentry & Migration config & so is fundamental to booting + // However, it involves reading package.json so its slow & it's here for visibility on that slowness + debug('Begin: Load version info'); + require('@tryghost/version'); + debug('End: Load version info'); + + // Loading config must be the first thing we do, because it is required for absolutely everything debug('Begin: Load config'); config = require('./shared/config'); debug('End: Load config'); - // Logging is used absolutely everywhere + // Logging is also used absolutely everywhere debug('Begin: Load logging'); logging = require('@tryghost/logging'); metrics = require('@tryghost/metrics'); @@ -331,12 +338,6 @@ async function bootGhost() { try { // Step 1 - require more fundamental components - // Version is required by sentry & Migration config & so is fundamental to booting - // However, it involves reading package.json so its slow & it's here for visibility on that slowness - debug('Begin: Load version info'); - require('@tryghost/version'); - debug('End: Load version info'); - // Sentry must be initialized early, but requires config debug('Begin: Load sentry'); require('./shared/sentry');