2015-05-28 17:16:09 +02:00
|
|
|
// # Ghost Startup
|
|
|
|
// Orchestrates the startup of Ghost when run from command line.
|
2017-02-17 16:27:02 +01:00
|
|
|
|
2020-04-25 22:06:33 +02:00
|
|
|
const startTime = Date.now();
|
|
|
|
const debug = require('ghost-ignition').debug('boot:index');
|
|
|
|
const sentry = require('./core/server/sentry');
|
2017-02-17 16:27:02 +01:00
|
|
|
|
|
|
|
debug('First requires...');
|
|
|
|
|
2020-04-25 22:06:33 +02:00
|
|
|
const ghost = require('./core');
|
2017-02-17 16:27:02 +01:00
|
|
|
|
|
|
|
debug('Required ghost');
|
|
|
|
|
2020-04-25 22:06:33 +02:00
|
|
|
const express = require('express');
|
|
|
|
const common = require('./core/server/lib/common');
|
|
|
|
const urlService = require('./core/frontend/services/url');
|
|
|
|
const parentApp = express();
|
2016-06-03 10:06:18 +02:00
|
|
|
|
2020-01-29 13:09:21 +01:00
|
|
|
parentApp.use(sentry.requestHandler);
|
|
|
|
|
2016-10-03 10:33:14 +02:00
|
|
|
debug('Initialising Ghost');
|
2020-04-25 22:06:33 +02:00
|
|
|
|
2014-09-19 18:17:58 +02:00
|
|
|
ghost().then(function (ghostServer) {
|
2015-05-28 17:16:09 +02:00
|
|
|
// Mount our Ghost instance on our desired subdirectory path if it exists.
|
2017-12-11 19:14:05 +01:00
|
|
|
parentApp.use(urlService.utils.getSubdir(), ghostServer.rootApp);
|
2014-08-23 22:42:44 +02:00
|
|
|
|
2016-10-03 10:33:14 +02:00
|
|
|
debug('Starting Ghost');
|
2015-05-28 17:16:09 +02:00
|
|
|
// Let Ghost handle starting our server instance.
|
2018-07-27 15:19:39 +02:00
|
|
|
return ghostServer.start(parentApp)
|
|
|
|
.then(function afterStart() {
|
|
|
|
common.logging.info('Ghost boot', (Date.now() - startTime) / 1000 + 's');
|
|
|
|
});
|
2017-01-26 13:12:00 +01:00
|
|
|
}).catch(function (err) {
|
2018-08-22 13:28:31 +02:00
|
|
|
common.logging.error(err);
|
|
|
|
setTimeout(() => {
|
|
|
|
process.exit(-1);
|
|
|
|
}, 100);
|
2014-08-19 18:36:46 +02:00
|
|
|
});
|