feat: backport database selector flag
This commit is contained in:
parent
c819a354bc
commit
81fa63f630
3 changed files with 12 additions and 8 deletions
1
.env
Normal file
1
.env
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
LAMASSU_DB=RELEASE
|
||||||
|
|
@ -2,8 +2,15 @@ const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const os = require('os')
|
const os = require('os')
|
||||||
const argv = require('minimist')(process.argv.slice(2))
|
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 dbMapping = psqlConf => ({
|
||||||
|
STRESS_TEST: _.replace('lamassu', 'lamassu_stress', psqlConf),
|
||||||
|
RELEASE: _.replace('lamassu', 'lamassu_release', psqlConf),
|
||||||
|
DEV: _.replace('lamassu', 'lamassu', psqlConf)
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {{path: string, opts: any}}
|
* @return {{path: string, opts: any}}
|
||||||
|
|
@ -32,9 +39,7 @@ function load () {
|
||||||
opts: JSON.parse(fs.readFileSync(globalConfigPath))
|
opts: JSON.parse(fs.readFileSync(globalConfigPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argv.testDB) {
|
config.opts.postgresql = dbMapping(config.opts.postgresql)[process.env.LAMASSU_DB]
|
||||||
config.opts.postgresql = STRESS_TEST_DB
|
|
||||||
}
|
|
||||||
|
|
||||||
return config
|
return config
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
|
|
@ -45,9 +50,7 @@ function load () {
|
||||||
opts: JSON.parse(fs.readFileSync(homeConfigPath))
|
opts: JSON.parse(fs.readFileSync(homeConfigPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argv.testDB) {
|
config.opts.postgresql = dbMapping(config.opts.postgresql)[process.env.LAMASSU_DB]
|
||||||
config.opts.postgresql = STRESS_TEST_DB
|
|
||||||
}
|
|
||||||
|
|
||||||
return config
|
return config
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,5 @@ const cmd = require('./scripts')
|
||||||
process.on('message', async (msg) => {
|
process.on('message', async (msg) => {
|
||||||
console.log('Message from parent:', 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