mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Temporary fix for config loader
issue #1521 - Reverting some of the refactor towards including Ghost as a module as it prevented Ghost from loading when no config was available.
This commit is contained in:
parent
2701f3e664
commit
ab2eb18b86
2 changed files with 21 additions and 20 deletions
|
@ -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'),
|
||||
|
@ -21,8 +19,8 @@ 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.
|
||||
|
@ -30,19 +28,6 @@ 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.
|
||||
|
@ -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
index.js
10
index.js
|
@ -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);
|
Loading…
Reference in a new issue