Merge pull request #886 from chaotixkilla/feat-backport-database-selector-flag
Backport database selector flag
This commit is contained in:
commit
8c88c9064d
4 changed files with 15 additions and 8 deletions
1
.env.sample
Normal file
1
.env.sample
Normal file
|
|
@ -0,0 +1 @@
|
|||
LAMASSU_DB=DEV
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -40,3 +40,4 @@ terraform.*
|
|||
.terraform
|
||||
|
||||
db.json
|
||||
.env
|
||||
|
|
|
|||
|
|
@ -2,8 +2,17 @@ const fs = require('fs')
|
|||
const path = require('path')
|
||||
const os = require('os')
|
||||
const argv = require('minimist')(process.argv.slice(2))
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const STRESS_TEST_DB = 'psql://postgres:postgres123@localhost/lamassu_stress'
|
||||
require('dotenv').config()
|
||||
|
||||
const dbPath = !process.env.LAMASSU_DB ? 'PROD' : process.env.LAMASSU_DB
|
||||
const dbMapping = psqlConf => ({
|
||||
STRESS_TEST: _.replace('lamassu', 'lamassu_stress', psqlConf),
|
||||
RELEASE: _.replace('lamassu', 'lamassu_release', psqlConf),
|
||||
DEV: _.replace('lamassu', 'lamassu', psqlConf),
|
||||
PROD: _.replace('lamassu', 'lamassu', psqlConf)
|
||||
})
|
||||
|
||||
/**
|
||||
* @return {{path: string, opts: any}}
|
||||
|
|
@ -32,9 +41,7 @@ function load () {
|
|||
opts: JSON.parse(fs.readFileSync(globalConfigPath))
|
||||
}
|
||||
|
||||
if (argv.testDB) {
|
||||
config.opts.postgresql = STRESS_TEST_DB
|
||||
}
|
||||
config.opts.postgresql = dbMapping(config.opts.postgresql)[dbPath]
|
||||
|
||||
return config
|
||||
} catch (_) {
|
||||
|
|
@ -45,9 +52,7 @@ function load () {
|
|||
opts: JSON.parse(fs.readFileSync(homeConfigPath))
|
||||
}
|
||||
|
||||
if (argv.testDB) {
|
||||
config.opts.postgresql = STRESS_TEST_DB
|
||||
}
|
||||
config.opts.postgresql = dbMapping(config.opts.postgresql)[dbPath]
|
||||
|
||||
return config
|
||||
} catch (_) {
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@ const cmd = require('./scripts')
|
|||
process.on('message', async (msg) => {
|
||||
console.log('Message from parent:', msg)
|
||||
|
||||
await cmd.execCommand(`node --prof ../../bin/lamassu-server --mockSms --testDB`)
|
||||
await cmd.execCommand(`node --prof LAMASSU_DB=STRESS_TEST ../../bin/lamassu-server --mockSms`)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue