mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Renamed withBackend/withFrotned to backend/frontend
refs https://github.com/TryGhost/Toolbox/issues/135 - Shorter name still makes sense and the "with" might be causing confusion understanding what's gonig on during the boot time
This commit is contained in:
parent
149c100b4c
commit
bbc93ff996
7 changed files with 35 additions and 32 deletions
22
core/boot.js
22
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<object>} 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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue