mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 09:52:06 +03:00
57a8bf229e
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
27 lines
805 B
JavaScript
27 lines
805 B
JavaScript
// ## Server Loader
|
|
// Passes options through the boot process to get a server instance back
|
|
const server = require('./server');
|
|
const common = require('./server/lib/common');
|
|
const GhostServer = require('./server/ghost-server');
|
|
|
|
// Set the default environment to be `development`
|
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
|
|
function makeGhost(options) {
|
|
options = options || {};
|
|
|
|
return server(options)
|
|
.catch((err) => {
|
|
if (!common.errors.utils.isIgnitionError(err)) {
|
|
err = new common.errors.GhostError({message: err.message, err: err});
|
|
}
|
|
|
|
return GhostServer.announceServerStopped(err)
|
|
.finally(() => {
|
|
throw err;
|
|
});
|
|
});
|
|
}
|
|
|
|
module.exports = makeGhost;
|