mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
71f02d25e9
- the announce functions exist for the purpose of communicating with Ghost CLI - the functions were called announceServerStart and announceServerStopped, which implies they tell Ghost CLI when the server starts and stops - however, the true intention / purpose of these functions is to: - either tell Ghost CLI when Ghost has successfully booted (e.g. is ready to serve requests) - or tell Ghost CLI when the server failed to boot, and report the error so that Ghost CLI can communicate it to the user - therefore, I've refactored the old functions into 1 function to make it clearer they do the same job, but with 2 different states - also added some tests :D
27 lines
790 B
JavaScript
27 lines
790 B
JavaScript
// ## Server Loader
|
|
// Passes options through the boot process to get a server instance back
|
|
const server = require('./server');
|
|
const errors = require('@tryghost/errors');
|
|
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 (!errors.utils.isIgnitionError(err)) {
|
|
err = new errors.GhostError({message: err.message, err: err});
|
|
}
|
|
|
|
return GhostServer.announceServerReadiness(err)
|
|
.finally(() => {
|
|
throw err;
|
|
});
|
|
});
|
|
}
|
|
|
|
module.exports = makeGhost;
|