diff --git a/core/boot.js b/core/boot.js index 0ba9675290..3ac48828ae 100644 --- a/core/boot.js +++ b/core/boot.js @@ -69,9 +69,9 @@ async function initDatabase({config, logging}) { * @param {object} options.ghostServer * @param {object} options.config * @param {object} options.bootLogger - * @param {boolean} options.withFrontend + * @param {boolean} options.frontend */ -async function initCore({ghostServer, config, bootLogger, withFrontend}) { +async function initCore({ghostServer, config, bootLogger, frontend}) { debug('Begin: initCore'); // URL Utils is a bit slow, put it here so the timing is visible separate from models @@ -102,7 +102,7 @@ async function initCore({ghostServer, config, bootLogger, withFrontend}) { onFinished: () => { bootLogger.log('URL Service Ready'); }, - urlCache: !withFrontend // hacky parameter to make the cache initialization kick in as we can't initialize labs before the boot + urlCache: !frontend // hacky parameter to make the cache initialization kick in as we can't initialize labs before the boot }); debug('End: Url Service'); @@ -162,8 +162,8 @@ async function initFrontend() { * What we want is to be able to optionally load various components and mount them * So eventually this function should go away * @param {Object} options - * @param {Boolean} options.withBackend - * @param {Boolean} options.withFrontend + * @param {Boolean} options.backend + * @param {Boolean} options.frontend */ async function initExpressApps(options) { debug('Begin: initExpressApps'); @@ -302,7 +302,7 @@ async function initBackgroundServices({config}) { * @returns {Promise} ghostServer */ -async function bootGhost({withBackend = true, withFrontend = true} = {}) { +async function bootGhost({backend = true, frontend = true} = {}) { // Metrics const startTime = Date.now(); debug('Begin Boot'); @@ -352,7 +352,7 @@ async function bootGhost({withBackend = true, withFrontend = true} = {}) { debug('Begin: load server + minimal app'); const rootApp = require('./app'); - if (withBackend) { + if (backend) { const GhostServer = require('./server/ghost-server'); ghostServer = new GhostServer({url: config.getSiteUrl()}); await ghostServer.start(rootApp); @@ -368,15 +368,15 @@ async function bootGhost({withBackend = true, withFrontend = true} = {}) { // Step 4 - Load Ghost with all its services debug('Begin: Load Ghost Services & Apps'); - await initCore({ghostServer, config, bootLogger, withFrontend}); + await initCore({ghostServer, config, bootLogger, frontend}); - if (withFrontend) { + if (frontend) { await initServicesForFrontend(); await initFrontend(); } - const ghostApp = await initExpressApps({withFrontend, withBackend}); + const ghostApp = await initExpressApps({frontend, backend}); - if (withFrontend) { + if (frontend) { await initDynamicRouting(); } diff --git a/core/server/web/parent/app.js b/core/server/web/parent/app.js index 587ebe1fab..67ead46fc6 100644 --- a/core/server/web/parent/app.js +++ b/core/server/web/parent/app.js @@ -8,10 +8,10 @@ const vhost = require('@tryghost/vhost-middleware'); /** * @param {Object} options * @param {Boolean} [options.start] - * @param {Boolean} [options.withBackend] - * @param {Boolean} [options.withFrontend] + * @param {Boolean} [options.backend] + * @param {Boolean} [options.frontend] */ -module.exports = function setupParentApp({start, withFrontend = true, withBackend = true}) { +module.exports = function setupParentApp({start, frontend = true, backend = true}) { debug('ParentApp setup start'); const parentApp = express('parent'); @@ -32,13 +32,13 @@ module.exports = function setupParentApp({start, withFrontend = true, withBacken // Mount the express apps on the parentApp - if (withBackend) { + if (backend) { debug('Mounting bakcend: ADMIN + API'); const backendApp = require('./backend')(); parentApp.use(vhost(config.getBackendMountPath(), backendApp)); } - if (withFrontend) { + if (frontend) { debug('Mounting frontend: SITE + MEMBERS'); const frontendApp = require('./frontend')({start}); parentApp.use(vhost(config.getFrontendMountPath(), frontendApp)); diff --git a/test/e2e-api/admin/custom_theme_settings.test.js b/test/e2e-api/admin/custom_theme_settings.test.js index 644e0bd3cd..3049e75e00 100644 --- a/test/e2e-api/admin/custom_theme_settings.test.js +++ b/test/e2e-api/admin/custom_theme_settings.test.js @@ -12,7 +12,7 @@ describe('Custom Theme Settings API', function () { // NOTE: needs force start to be able to reinitialize Ghost process with frontend services - custom-theme-settings, to be specific await localUtils.startGhost({ forceStart: true, - withFrontend: true + frontend: true }); request = supertest.agent(config.get('url')); await localUtils.doAuth(request, 'users:extra', 'custom_theme_settings'); diff --git a/test/e2e-api/admin/themes.test.js b/test/e2e-api/admin/themes.test.js index 6c3092aa1c..aadf41a7cd 100644 --- a/test/e2e-api/admin/themes.test.js +++ b/test/e2e-api/admin/themes.test.js @@ -26,9 +26,12 @@ describe('Themes API', function () { }; before(async function () { + // NOTE: this flag should not be here! the URL service re-initialization should be fixed instead + // The reason why this init doesn't work without "forceStart" is because during the "restartModeGhostStart" + // the routing.routerManager is never called with "start". That's why a full boot is needed await localUtils.startGhost({ - forceStart: true, // NOTE: this flag should not be here! the URL service re-initialization should be fixe instead - withFrontend: true + forceStart: true, + frontend: true }); ownerRequest = supertest.agent(config.get('url')); await localUtils.doAuth(ownerRequest); diff --git a/test/e2e-api/admin/utils.js b/test/e2e-api/admin/utils.js index b6626fad9a..2e2a61b689 100644 --- a/test/e2e-api/admin/utils.js +++ b/test/e2e-api/admin/utils.js @@ -211,8 +211,8 @@ module.exports = { async startGhost(overrides = {}) { const defaults = { - withBackend: true, - withFrontend: false + backend: true, + frontend: false }; return await testUtils.startGhost(Object.assign(defaults, overrides)); diff --git a/test/e2e-api/content/utils.js b/test/e2e-api/content/utils.js index 3cb25c2508..aefdeba282 100644 --- a/test/e2e-api/content/utils.js +++ b/test/e2e-api/content/utils.js @@ -99,8 +99,8 @@ module.exports = { }, async startGhost(overrides = {}) { const defaults = { - withBackend: true, - withFrontend: false + backend: true, + frontend: false }; return await testUtils.startGhost(Object.assign(defaults, overrides)); diff --git a/test/utils/e2e-utils.js b/test/utils/e2e-utils.js index e81a26ed56..d936ffc7ce 100644 --- a/test/utils/e2e-utils.js +++ b/test/utils/e2e-utils.js @@ -96,7 +96,7 @@ const prepareContentFolder = (options) => { // - truncate database // - re-run default fixtures // - reload affected services -const restartModeGhostStart = async ({withFrontend}) => { +const restartModeGhostStart = async ({frontend}) => { debug('Reload Mode'); // Teardown truncates all tables and also calls urlServiceUtils.reset(); await dbUtils.teardown(); @@ -109,7 +109,7 @@ const restartModeGhostStart = async ({withFrontend}) => { await settingsService.init(); debug('settings done'); - if (withFrontend) { + if (frontend) { // Load the frontend-related components await routeSettingsService.init(); await themeService.init(); @@ -119,9 +119,9 @@ const restartModeGhostStart = async ({withFrontend}) => { // Reload the URL service & wait for it to be ready again // @TODO: why/how is this different to urlService.resetGenerators? urlServiceUtils.reset(); - urlServiceUtils.init({urlCache: !withFrontend}); + urlServiceUtils.init({urlCache: !frontend}); - if (withFrontend) { + if (frontend) { await urlServiceUtils.isFinished(); } @@ -133,8 +133,8 @@ const restartModeGhostStart = async ({withFrontend}) => { limits.init(); }; -const bootGhost = async ({withBackend, withFrontend}) => { - ghostServer = await boot({withBackend, withFrontend}); +const bootGhost = async ({backend, frontend}) => { + ghostServer = await boot({backend, frontend}); }; // CASE: Ghost Server needs Starting @@ -174,7 +174,7 @@ const freshModeGhostStart = async (options) => { await bootGhost(options); // Wait for the URL service to be ready, which happens after bootYou - if (options.withFrontend) { + if (options.frontend) { await urlServiceUtils.isFinished(); } }; @@ -183,8 +183,8 @@ const startGhost = async (options) => { const startTime = Date.now(); debug('Start Ghost'); options = _.merge({ - withBackend: true, - withFrontend: true, + backend: true, + frontend: true, redirectsFile: true, redirectsFileExt: '.json', forceStart: false,