mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Refactored minimal setup for Ghost boot
refs #12568 - Moved duplicated initialization code to make initialization stages clearer
This commit is contained in:
parent
75cacc460b
commit
9163c48f4e
1 changed files with 6 additions and 10 deletions
|
@ -16,7 +16,6 @@ const {events, i18n} = require('./lib/common');
|
||||||
const logging = require('../shared/logging');
|
const logging = require('../shared/logging');
|
||||||
const migrator = require('./data/db/migrator');
|
const migrator = require('./data/db/migrator');
|
||||||
const urlUtils = require('./../shared/url-utils');
|
const urlUtils = require('./../shared/url-utils');
|
||||||
let parentApp;
|
|
||||||
|
|
||||||
// Frontend Components
|
// Frontend Components
|
||||||
const themeService = require('../frontend/services/themes');
|
const themeService = require('../frontend/services/themes');
|
||||||
|
@ -114,7 +113,7 @@ const minimalRequiredSetupToStartGhost = async (dbState) => {
|
||||||
await themeService.init();
|
await themeService.init();
|
||||||
debug('Themes done');
|
debug('Themes done');
|
||||||
|
|
||||||
parentApp = require('./web/parent/app')();
|
const parentApp = require('./web/parent/app')();
|
||||||
debug('Express Apps done');
|
debug('Express Apps done');
|
||||||
|
|
||||||
ghostServer = new GhostServer(parentApp);
|
ghostServer = new GhostServer(parentApp);
|
||||||
|
@ -128,15 +127,12 @@ const minimalRequiredSetupToStartGhost = async (dbState) => {
|
||||||
events.emit('db.ready');
|
events.emit('db.ready');
|
||||||
|
|
||||||
await initialiseServices();
|
await initialiseServices();
|
||||||
initializeRecurringJobs();
|
|
||||||
return ghostServer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CASE: migrations required, put blog into maintenance mode
|
// CASE: migrations required, put blog into maintenance mode
|
||||||
if (dbState === 4) {
|
if (dbState === 4) {
|
||||||
logging.info('Blog is in maintenance mode.');
|
|
||||||
|
|
||||||
config.set('maintenance:enabled', true);
|
config.set('maintenance:enabled', true);
|
||||||
|
logging.info('Blog is in maintenance mode.');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await migrator.migrate();
|
await migrator.migrate();
|
||||||
|
@ -150,10 +146,6 @@ const minimalRequiredSetupToStartGhost = async (dbState) => {
|
||||||
logging.info('Blog is out of maintenance mode.');
|
logging.info('Blog is out of maintenance mode.');
|
||||||
|
|
||||||
await GhostServer.announceServerReadiness();
|
await GhostServer.announceServerReadiness();
|
||||||
|
|
||||||
initializeRecurringJobs();
|
|
||||||
|
|
||||||
return ghostServer;
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
try {
|
try {
|
||||||
await GhostServer.announceServerReadiness(err);
|
await GhostServer.announceServerReadiness(err);
|
||||||
|
@ -165,6 +157,10 @@ const minimalRequiredSetupToStartGhost = async (dbState) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initializeRecurringJobs();
|
||||||
|
|
||||||
|
return ghostServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue