Added Sentry to new boot process

- With the new boot finalised it's clearer to see where this needs to go
- Update comments to add more clarity around what's happening and why
- Cleaned up the version require, as this was prep for maybe using version via config, which won't work in MigratorConfig
This commit is contained in:
Hannah Wolfe 2021-02-19 09:10:45 +00:00
parent ab65f70ef1
commit 4b472615a8
2 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,5 @@
const sentry = require('./shared/sentry');
const express = require('./shared/express');
const rootApp = express('root');
const fs = require('fs');
const path = require('path');
@ -16,6 +16,9 @@ const maintenanceMiddleware = (req, res, next) => {
fs.createReadStream(path.resolve(__dirname, './server/views/maintenance.html')).pipe(res);
};
const rootApp = express('root');
rootApp.use(sentry.requestHandler);
rootApp.enable('maintenance');
rootApp.use(maintenanceMiddleware);

View File

@ -111,7 +111,7 @@ const mountGhost = (rootApp, ghostApp) => {
};
const bootGhost = async () => {
// Metrics & debugging
// Metrics
const startTime = Date.now();
let ghostServer;
@ -121,11 +121,17 @@ const bootGhost = async () => {
const config = require('./shared/config');
debug('End: Load config');
// Version is required by sentry & Migratior config & so is fundamental to booting
// However, it involves reading package.json, so put it here for visibility on how slow it is
debug('Begin: Load version info');
const version = require('./server/lib/ghost-version');
config.set('version', version);
require('./server/lib/ghost-version');
debug('End: Load version info');
// Sentry must be initialised early, but requires config
debug('Begin: Load sentry');
require('./shared/sentry');
debug('End: Load sentry');
debug('Begin: load server + minimal app');
process.env.NODE_ENV = process.env.NODE_ENV || 'development';