0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

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
This commit is contained in:
Hannah Wolfe 2021-11-16 14:44:14 +00:00
parent b781e47cb9
commit 9a8b18a473
No known key found for this signature in database
GPG key ID: 9F8C7532D0A6BA55

View file

@ -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');