mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
31b693da1f
- Should prevent Ghost from exiting without an error message
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)
|
|
.otherwise(function (e) {
|
|
// We don't return the rejected promise to stop
|
|
// the propogation of the rejection and just
|
|
// allow the user to manage what to do.
|
|
deferred.reject(e);
|
|
});
|
|
} catch (e) {
|
|
deferred.reject(e);
|
|
}
|
|
});
|
|
|
|
return deferred.promise;
|
|
}
|
|
|
|
module.exports = startGhost; |