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