mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 13:22:39 +03:00
258a3cdb40
Refs #2986 -More thorough promise handling in bootstrap.js -Catch rejected promises from the bootstrap module and force a Grunt failure instead of an erroneous success -Adjust the bootstrap unit tests fix
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
// # Ghost bootloader
|
|
// Orchestrates the loading of Ghost
|
|
// When run from command line.
|
|
|
|
var when = require('when'),
|
|
bootstrap = require('./bootstrap');
|
|
|
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
|
|
function startGhost(options) {
|
|
// When we no longer need to require('./server')
|
|
// in a callback this extra deferred object
|
|
// won't be necessary, we'll just be able to return
|
|
// the server object directly.
|
|
var deferred = when.defer();
|
|
|
|
options = options || {};
|
|
|
|
bootstrap(options.config).then(function () {
|
|
try {
|
|
var ghost = require('./server');
|
|
return ghost(options.app)
|
|
.then(deferred.resolve)
|
|
.catch(function (err) {
|
|
// We don't return the rejected promise to stop
|
|
// the propagation of the rejection and just
|
|
// allow the user to manage what to do.
|
|
deferred.reject(err);
|
|
});
|
|
} catch (e) {
|
|
deferred.reject(e);
|
|
}
|
|
}).catch(deferred.reject);
|
|
|
|
return deferred.promise;
|
|
}
|
|
|
|
module.exports = startGhost; |