mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-09-11 12:55:37 +03:00
closes #9802 - we have to trigger both functions within Ghost core, otherwise people who are using Ghost as NPM module have to call these functions - this is internal logic - plus: this logic is conditional, because of our internal maintenance flag - make it backwards compatible in case you call announceServerStart or announceServerStopped twice - tested with "Ghost as NPM module" and with the CLI on production
36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
// # Ghost Startup
|
|
// Orchestrates the startup of Ghost when run from command line.
|
|
|
|
var startTime = Date.now(),
|
|
debug = require('ghost-ignition').debug('boot:index'),
|
|
ghost, express, common, urlService, parentApp;
|
|
|
|
debug('First requires...');
|
|
|
|
ghost = require('./core');
|
|
|
|
debug('Required ghost');
|
|
|
|
express = require('express');
|
|
common = require('./core/server/lib/common');
|
|
urlService = require('./core/server/services/url');
|
|
parentApp = express();
|
|
|
|
debug('Initialising Ghost');
|
|
ghost().then(function (ghostServer) {
|
|
// Mount our Ghost instance on our desired subdirectory path if it exists.
|
|
parentApp.use(urlService.utils.getSubdir(), ghostServer.rootApp);
|
|
|
|
debug('Starting Ghost');
|
|
// Let Ghost handle starting our server instance.
|
|
return ghostServer.start(parentApp)
|
|
.then(function afterStart() {
|
|
common.logging.info('Ghost boot', (Date.now() - startTime) / 1000 + 's');
|
|
});
|
|
}).catch(function (err) {
|
|
common.logging.error(err);
|
|
setTimeout(() => {
|
|
process.exit(-1);
|
|
}, 100);
|
|
});
|