1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00

#18 reading db-config from DATABASE_URL or ini-file

This commit is contained in:
Ivar Conradi Østhus 2014-10-23 10:05:56 +02:00
parent 73668d79b5
commit b76b4d2093
3 changed files with 11 additions and 7 deletions

View File

@ -6,17 +6,19 @@ var anyDB = require('any-db'),
function createDbPool() {
if (nconf.argv().get('databaseini') !== undefined) {
// Use postgres db from DATABASE_URL if set
if (process.env.DATABASE_URL) {
logger.info('unleash started with DATABASE_URL');
return anyDB.createPool(process.env.DATABASE_URL);
}
// Finn specific way of delivering env variables
else if(nconf.argv().get('databaseini') !== undefined) {
var databaseini = nconf.argv().get('databaseini');
logger.info('unleash started with databaseini: ' + databaseini);
var config = ini.parse(fs.readFileSync(databaseini, 'utf-8'));
return anyDB.createPool(config.DATABASE_URL, {min: 2, max: 20});
}
}
module.exports = {
pool: createDbPool()
};
module.exports = createDbPool();

View File

@ -1,5 +1,6 @@
var Promise = require('bluebird'),
util = require('util'),
dbPool = require('./dbPool'),
EventEmitter = require('events').EventEmitter;
function EventStore() {

View File

@ -40,6 +40,7 @@
"nconf": "0.6.9",
"pg": "^3.6.1",
"any-db": "2.1.0",
"any-db-pool": "2.1.0",
"any-db-postgres": "2.1.3"
},
"devDependencies": {