mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
f9d4d01088
no issue - if we trigger the IPC message to the CLI and the process manager is systemd, systemd will restart Ghost too early (same for local process manager) - this is a timing issue - the consequence is that the error log won't happen in Ghost (`content/logs/[domain].error.log` won't contain that error) - let's reorder both executions [See](https://github.com/TryGhost/Ghost-CLI/pull/612/files#r165817172) this comment on the CLI PR.
48 lines
1.4 KiB
JavaScript
48 lines
1.4 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');
|
|
|
|
// if IPC messaging is enabled, ensure ghost sends message to parent
|
|
// process on successful start
|
|
if (process.send) {
|
|
process.send({started: true});
|
|
}
|
|
});
|
|
}).catch(function (err) {
|
|
if (!common.errors.utils.isIgnitionError(err)) {
|
|
err = new common.errors.GhostError({err: err});
|
|
}
|
|
|
|
common.logging.error(err);
|
|
|
|
if (process.send) {
|
|
process.send({started: false, error: err.message});
|
|
}
|
|
|
|
process.exit(-1);
|
|
});
|