Remove settings' app_root

This commit is contained in:
Raul Ochoa 2016-09-14 21:02:56 +02:00
parent f92d50cccf
commit 84b80547c2
3 changed files with 8 additions and 19 deletions

17
app.js
View File

@ -9,7 +9,6 @@
* environments: [development, test, production]
*
*/
var _ = require('underscore');
var fs = require('fs');
var path = require('path');
@ -31,10 +30,8 @@ if (availableEnvironments.indexOf(ENV) === -1) {
}
// set Node.js app settings and boot
global.settings = require(__dirname + '/config/settings');
var env = require(__dirname + '/config/environments/' + ENV);
env.api_hostname = require('os').hostname().split('.')[0];
_.extend(global.settings, env);
global.settings = require('./config/environments/' + ENV);
global.settings.api_hostname = require('os').hostname().split('.')[0];
global.log4js = require('log4js');
var log4jsConfig = {
@ -42,8 +39,8 @@ var log4jsConfig = {
replaceConsole: true
};
if ( env.log_filename ) {
var logFilename = path.resolve(env.log_filename);
if ( global.settings.log_filename ) {
var logFilename = path.resolve(global.settings.log_filename);
var logDirectory = path.dirname(logFilename);
if (!fs.existsSync(logDirectory)) {
console.error("Log filename directory does not exist: " + logDirectory);
@ -69,11 +66,11 @@ if ( ! global.settings.base_url ) {
var version = require("./package").version;
var server = require('app/server')();
var server = require('./app/server')();
server.listen(global.settings.node_port, global.settings.node_host, function() {
console.log(
"CartoDB SQL API %s listening on %s:%s with base_url %s (%s)",
version, global.settings.node_host, global.settings.node_port, global.settings.base_url, ENV
"CartoDB SQL API %s listening on %s:%s with base_url %s PID=%d (%s)",
version, global.settings.node_host, global.settings.node_port, global.settings.base_url, process.pid, ENV
);
});

View File

@ -1,4 +0,0 @@
var path = require('path');
module.exports.app_root = path.join(__dirname, '..');

View File

@ -1,5 +1 @@
var _ = require('underscore');
global.settings = require(__dirname + '/../config/settings');
var env = require(__dirname + '/../config/environments/test');
_.extend(global.settings, env);
global.settings = require('../config/environments/test');