0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-15 03:01:37 -05:00

Refactored urlUtils out of ghost-server

- We only require a single value from urlUtils, the url for the site
- Move that logic back to the boot file makes it much more explict
- Will help if we want to refactor how urlUtils works, or when we want to move ghost-server out of core
This commit is contained in:
Hannah Wolfe 2021-05-05 14:24:59 +01:00
parent 78cdd3fe13
commit c999e48c01
2 changed files with 9 additions and 6 deletions

View file

@ -264,11 +264,15 @@ async function bootGhost() {
require('./shared/sentry');
debug('End: Load sentry');
debug('Begin: Load urlUtils');
const urlUtils = require('./shared/url-utils');
debug('End: Load urlUtils');
// Step 2 - Start server with minimal app in global maintenance mode
debug('Begin: load server + minimal app');
const rootApp = require('./app');
const GhostServer = require('./server/ghost-server');
ghostServer = new GhostServer();
ghostServer = new GhostServer({url: urlUtils.urlFor('home', true)});
await ghostServer.start(rootApp);
bootLogger.log('server started');
debug('End: load server + minimal app');
@ -289,7 +293,6 @@ async function bootGhost() {
// Step 5 - Mount the full Ghost app onto the minimal root app & disable maintenance mode
debug('Begin: mountGhost');
const urlUtils = require('./shared/url-utils');
rootApp.disable('maintenance');
rootApp.use(urlUtils.getSubdir(), ghostApp);
debug('End: mountGhost');

View file

@ -7,7 +7,6 @@ const fs = require('fs-extra');
const path = require('path');
const _ = require('lodash');
const config = require('../shared/config');
const urlUtils = require('./../shared/url-utils');
const errors = require('@tryghost/errors');
const i18n = require('../shared/i18n');
const logging = require('../shared/logging');
@ -19,7 +18,8 @@ const stoppable = require('stoppable');
* ## GhostServer
*/
class GhostServer {
constructor() {
constructor({url}) {
this.url = url;
this.rootApp = null;
this.httpServer = null;
@ -260,13 +260,13 @@ class GhostServer {
logging.info(i18n.t('notices.httpServer.ghostIsRunningIn', {env: config.get('env')}));
if (config.get('env') === 'production') {
logging.info(i18n.t('notices.httpServer.yourBlogIsAvailableOn', {url: urlUtils.urlFor('home', true)}));
logging.info(i18n.t('notices.httpServer.yourBlogIsAvailableOn', {url: this.url}));
} else {
logging.info(i18n.t('notices.httpServer.listeningOn', {
host: config.get('server').socket || config.get('server').host,
port: config.get('server').port
}));
logging.info(i18n.t('notices.httpServer.urlConfiguredAs', {url: urlUtils.urlFor('home', true)}));
logging.info(i18n.t('notices.httpServer.urlConfiguredAs', {url: this.url}));
}
logging.info(i18n.t('notices.httpServer.ctrlCToShutDown'));