Skip to content

Commit

Permalink
Temporary fix for config loader
Browse files Browse the repository at this point in the history
issue #1521

- Reverting some of the refactor towards including Ghost as a module as it prevented Ghost from loading when no config was available.
  • Loading branch information
ErisDS committed Nov 23, 2013
1 parent 2701f3e commit ab2eb18
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
31 changes: 13 additions & 18 deletions core/server.js
@@ -1,11 +1,9 @@
// If no env is set, default to development
// This needs to be above all other require()
// modules to ensure config gets right setting.
process.env.NODE_ENV = process.env.NODE_ENV || 'development';

// Module dependencies
var configLoader = require('./config-loader.js'),
express = require('express'),
var express = require('express'),
when = require('when'),
_ = require('underscore'),
semver = require('semver'),
Expand All @@ -21,28 +19,15 @@ var configLoader = require('./config-loader.js'),

// Variables
ghost = new Ghost(),
init,
setup;
setup,
init;

// If we're in development mode, require "when/console/monitor"
// for help in seeing swallowed promise errors.
if (process.env.NODE_ENV === 'development') {
require('when/monitor/console');
}

// Initializes the ghost application.
function init(app) {
if (!app) {
app = express();
}

configLoader.loadConfig().then(function () {
// The server and its dependencies require a populated config
setup(app);
}).otherwise(errors.logAndThrowError);
}


// Sets up the express server instance.
// Instantiates the ghost singleton,
// helpers, routes, middleware, and plugins.
Expand Down Expand Up @@ -168,4 +153,14 @@ function setup(server) {
});
}

// Initializes the ghost application.
function init(app) {
if (!app) {
app = express();
}

// The server and its dependencies require a populated config
setup(app);
}

module.exports = init;
10 changes: 8 additions & 2 deletions index.js
Expand Up @@ -2,6 +2,12 @@
// Orchestrates the loading of Ghost
// When run from command line.

var ghost = require('./core/server');
var configLoader = require('./core/config-loader.js'),
errors = require('./core/server/errorHandling');

ghost();
process.env.NODE_ENV = process.env.NODE_ENV || 'development';

configLoader.loadConfig().then(function () {
var ghost = require('./core/server');
ghost();
}).otherwise(errors.logAndThrowError);

0 comments on commit ab2eb18

Please sign in to comment.