mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
Fail fast if DB is not configured
This commit is contained in:
parent
3fc8131a43
commit
d1f4b65c51
@ -6,19 +6,18 @@ var anyDB = require('any-db'),
|
|||||||
|
|
||||||
|
|
||||||
function createDbPool() {
|
function createDbPool() {
|
||||||
// Use postgres db from DATABASE_URL if set
|
|
||||||
if (process.env.DATABASE_URL) {
|
if (process.env.DATABASE_URL) {
|
||||||
logger.info('unleash started with DATABASE_URL');
|
logger.info('unleash started with DATABASE_URL');
|
||||||
return anyDB.createPool(process.env.DATABASE_URL);
|
return anyDB.createPool(process.env.DATABASE_URL);
|
||||||
}
|
} else if (nconf.argv().get('databaseini') !== undefined) {
|
||||||
|
|
||||||
// Finn specific way of delivering env variables
|
// 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});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw new Error('please set DATABASE_URL or pass --databaseini');
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = createDbPool();
|
module.exports = createDbPool();
|
Loading…
Reference in New Issue
Block a user