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