mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
Replaced themes.ready event with direct call
refs b1a98b0b67
- note: I already replaced server.start with themes.ready in the above commit
- events make the code harder to read/reason about
- long term it would be nice to have a concept of hooks for services, but for now explicit is clearer
This commit is contained in:
parent
9c96fbbe41
commit
dd715b33dc
26
core/boot.js
26
core/boot.js
@ -93,11 +93,6 @@ async function initFrontend() {
|
||||
async function initExpressApps() {
|
||||
debug('Begin: initExpressApps');
|
||||
const parentApp = require('./server/web/parent/app')();
|
||||
|
||||
// @TODO: fix this
|
||||
const {events} = require('./server/lib/common');
|
||||
events.emit('themes.ready');
|
||||
|
||||
debug('End: initExpressApps');
|
||||
return parentApp;
|
||||
}
|
||||
@ -157,22 +152,29 @@ async function initServices({config}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Kick off recurring and background jobs
|
||||
* Kick off recurring jobs and background services
|
||||
* These are things that happen on boot, but we don't need to wait for them to finish
|
||||
* Later, this might be a service hook
|
||||
*/
|
||||
async function initRecurringJobs({config}) {
|
||||
debug('Begin: initRecurringJobs');
|
||||
// we don't want to kick off scheduled/recurring jobs that will interfere with tests
|
||||
async function initBackgroundServices({config}) {
|
||||
debug('Begin: initBackgroundServices');
|
||||
|
||||
// we don't want to kick off background services that will interfere with tests
|
||||
if (process.env.NODE_ENV.match(/^testing/)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Load email analytics recurring jobs
|
||||
if (config.get('backgroundJobs:emailAnalytics')) {
|
||||
const emailAnalyticsJobs = require('./server/services/email-analytics/jobs');
|
||||
await emailAnalyticsJobs.scheduleRecurringJobs();
|
||||
}
|
||||
|
||||
debug('End: initRecurringJobs');
|
||||
// Load all inactive themes
|
||||
const themeService = require('./frontend/services/themes');
|
||||
themeService.loadInactiveThemes();
|
||||
|
||||
debug('End: initBackgroundServices');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -270,8 +272,8 @@ async function bootGhost() {
|
||||
|
||||
notifyServerReady();
|
||||
|
||||
// Init our background jobs, we don't wait for this to finish
|
||||
initRecurringJobs({config});
|
||||
// Init our background services, we don't wait for this to finish
|
||||
initBackgroundServices({config});
|
||||
|
||||
// We return the server for testing purposes
|
||||
debug('End Boot: Returning Ghost Server');
|
||||
|
@ -22,12 +22,6 @@ module.exports = {
|
||||
i18n.init(activeThemeName);
|
||||
|
||||
debug('init themes', activeThemeName);
|
||||
|
||||
// Register a listener for when the server says we can start to load all themes
|
||||
events.on('themes.ready', function readAllThemesOnReady() {
|
||||
themeLoader.loadAllThemes();
|
||||
});
|
||||
|
||||
// Just read the active theme for now
|
||||
return themeLoader
|
||||
.loadOneTheme(activeThemeName)
|
||||
@ -109,5 +103,11 @@ module.exports = {
|
||||
},
|
||||
storage: require('./storage'),
|
||||
middleware: require('./middleware'),
|
||||
loadCoreHelpers: require('./handlebars/helpers').loadCoreHelpers
|
||||
loadCoreHelpers: require('./handlebars/helpers').loadCoreHelpers,
|
||||
/**
|
||||
* Load all inactive themes
|
||||
*/
|
||||
loadInactiveThemes: async () => {
|
||||
return await themeLoader.loadAllThemes();
|
||||
}
|
||||
};
|
||||
|
@ -203,7 +203,7 @@ const restartModeGhostStart = async () => {
|
||||
web.shared.middlewares.customRedirects.reload();
|
||||
|
||||
// Trigger themes to load again
|
||||
events.emit('themes.ready');
|
||||
themes.loadInactiveThemes();
|
||||
};
|
||||
|
||||
const bootGhost = async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user