mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
1438278ce4
closes #3789 - Create a GhostServer class to manage state - index.js now calls start on the exported server - Alter tests to expect a GhostServer instance
34 lines
956 B
JavaScript
34 lines
956 B
JavaScript
// # Ghost bootloader
|
|
// Orchestrates the loading of Ghost
|
|
// When run from command line.
|
|
|
|
var when = require('when'),
|
|
bootstrap = require('./bootstrap'),
|
|
server = require('./server');
|
|
|
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
|
|
function makeGhost(options) {
|
|
var deferred = when.defer();
|
|
|
|
options = options || {};
|
|
|
|
bootstrap(options.config).then(function () {
|
|
try {
|
|
return server(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 = makeGhost;
|