2015-05-28 10:16:09 -05:00
|
|
|
// ## Server Loader
|
|
|
|
// Passes options through the boot process to get a server instance back
|
2018-08-22 06:28:31 -05:00
|
|
|
const server = require('./server');
|
2020-04-30 14:26:12 -05:00
|
|
|
const errors = require('@tryghost/errors');
|
2018-08-22 06:28:31 -05:00
|
|
|
const GhostServer = require('./server/ghost-server');
|
2013-11-25 22:22:59 -05:00
|
|
|
|
2015-05-28 10:16:09 -05:00
|
|
|
// Set the default environment to be `development`
|
2013-11-25 22:22:59 -05:00
|
|
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
|
|
|
2014-08-19 11:36:46 -05:00
|
|
|
function makeGhost(options) {
|
2014-02-08 10:41:15 -05:00
|
|
|
options = options || {};
|
2014-02-19 22:22:02 -05:00
|
|
|
|
2018-08-22 06:28:31 -05:00
|
|
|
return server(options)
|
|
|
|
.catch((err) => {
|
2020-04-30 14:26:12 -05:00
|
|
|
if (!errors.utils.isIgnitionError(err)) {
|
|
|
|
err = new errors.GhostError({message: err.message, err: err});
|
2018-08-22 06:28:31 -05:00
|
|
|
}
|
|
|
|
|
2020-08-09 10:40:47 -05:00
|
|
|
return GhostServer.announceServerReadiness(err)
|
2018-08-22 06:28:31 -05:00
|
|
|
.finally(() => {
|
|
|
|
throw err;
|
|
|
|
});
|
|
|
|
});
|
2013-11-25 22:22:59 -05:00
|
|
|
}
|
|
|
|
|
2014-08-19 11:36:46 -05:00
|
|
|
module.exports = makeGhost;
|