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:
parent
73668d79b5
commit
b76b4d2093
@ -6,17 +6,19 @@ var anyDB = require('any-db'),
|
|||||||
|
|
||||||
|
|
||||||
function createDbPool() {
|
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');
|
var databaseini = nconf.argv().get('databaseini');
|
||||||
|
|
||||||
logger.info('unleash started with databaseini: ' + databaseini);
|
logger.info('unleash started with databaseini: ' + databaseini);
|
||||||
|
|
||||||
var config = ini.parse(fs.readFileSync(databaseini, 'utf-8'));
|
var config = ini.parse(fs.readFileSync(databaseini, 'utf-8'));
|
||||||
|
|
||||||
return anyDB.createPool(config.DATABASE_URL, {min: 2, max: 20});
|
return anyDB.createPool(config.DATABASE_URL, {min: 2, max: 20});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = createDbPool();
|
||||||
pool: createDbPool()
|
|
||||||
};
|
|
@ -1,5 +1,6 @@
|
|||||||
var Promise = require('bluebird'),
|
var Promise = require('bluebird'),
|
||||||
util = require('util'),
|
util = require('util'),
|
||||||
|
dbPool = require('./dbPool'),
|
||||||
EventEmitter = require('events').EventEmitter;
|
EventEmitter = require('events').EventEmitter;
|
||||||
|
|
||||||
function EventStore() {
|
function EventStore() {
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
"nconf": "0.6.9",
|
"nconf": "0.6.9",
|
||||||
"pg": "^3.6.1",
|
"pg": "^3.6.1",
|
||||||
"any-db": "2.1.0",
|
"any-db": "2.1.0",
|
||||||
|
"any-db-pool": "2.1.0",
|
||||||
"any-db-postgres": "2.1.3"
|
"any-db-postgres": "2.1.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
Loading…
Reference in New Issue
Block a user