* dev: (85 commits) chore: console.log debug leftovers fix: third level navigation links fix: show subheader on refresh fix: machines/:id routing fix: customer route chore: update wallet nodes feat: shorten long addresses in funding page feat: shorten long addresses refactor: support copied text different from presented text chore: udpate react, downshift and routing refactor: use Wizard component on first route fix: autocomplete component rendering feat: skip2fa option on .env fix: drop contraint before dropping index chore: stop using alias imports fix: re-instate urlResolver chore: server code formatting chore: reformat code chore: adding eslint and prettier config chore: typo ...
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
const { fork } = require('node:child_process')
|
|
const { join } = require('node:path')
|
|
|
|
const { EXIT } = require('./consts')
|
|
const CLI = require('./cli')
|
|
|
|
const help_message = 'Start the server configured for stress testing.'
|
|
|
|
const cli = CLI({
|
|
grammar: [[['--help'], 'Show this help message']],
|
|
})
|
|
|
|
const help = exit_code => {
|
|
console.log('Usage: lamassu-server-stress-testing server ARGS...')
|
|
console.log(help_message)
|
|
cli.help()
|
|
return exit_code
|
|
}
|
|
|
|
const start_server = args =>
|
|
new Promise(resolve => {
|
|
const lamassu_server = join(__dirname, '../../bin/lamassu-server')
|
|
const ls = fork(lamassu_server, args, {
|
|
cwd: process.cwd(),
|
|
encoding: 'utf8',
|
|
env: { LAMASSU_STRESS_TESTING: 'YES' },
|
|
})
|
|
|
|
ls.on('error', error => {
|
|
console.log(error)
|
|
resolve(EXIT.EXCEPTION)
|
|
})
|
|
|
|
ls.on('exit', (code, signal) => {
|
|
console.error('lamassu-server code:', code)
|
|
console.error('lamassu-server signal:', signal)
|
|
resolve(typeof code === 'number' ? code : EXIT.EXCEPTION)
|
|
})
|
|
})
|
|
|
|
const run = async args => {
|
|
const [err, options, positional] = cli.parse(args)
|
|
if (err) {
|
|
console.error(err)
|
|
return help(EXIT.BADARGS)
|
|
}
|
|
|
|
if (options.help) return help(EXIT.OK)
|
|
|
|
return await start_server(positional)
|
|
}
|
|
|
|
module.exports = {
|
|
help_message,
|
|
run,
|
|
}
|