Add inspect to test script

pull/3385/head
Chocobozzz 2020-11-30 14:47:54 +01:00
parent f45c7cc770
commit bd2e2f11d0
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 14 additions and 8 deletions

View File

@ -39,7 +39,7 @@ async function run () {
console.log('Starting server.') console.log('Starting server.')
const server = await flushAndRunServer(1, {}, [], false) const server = await flushAndRunServer(1, {}, [], { hideLogs: false, execArgv: [ '--inspect' ] })
const cleanup = () => { const cleanup = () => {
console.log('Killing server') console.log('Killing server')

View File

@ -104,7 +104,12 @@ function randomRTMP () {
return randomInt(low, high) return randomInt(low, high)
} }
async function flushAndRunServer (serverNumber: number, configOverride?: Object, args = [], silent = true) { type RunServerOptions = {
hideLogs?: boolean
execArgv?: string[]
}
async function flushAndRunServer (serverNumber: number, configOverride?: Object, args = [], options: RunServerOptions = {}) {
const parallel = parallelTests() const parallel = parallelTests()
const internalServerNumber = parallel ? randomServer() : serverNumber const internalServerNumber = parallel ? randomServer() : serverNumber
@ -133,10 +138,10 @@ async function flushAndRunServer (serverNumber: number, configOverride?: Object,
} }
} }
return runServer(server, configOverride, args, silent) return runServer(server, configOverride, args, options)
} }
async function runServer (server: ServerInfo, configOverrideArg?: any, args = [], silent?: boolean) { async function runServer (server: ServerInfo, configOverrideArg?: any, args = [], options: RunServerOptions = {}) {
// These actions are async so we need to be sure that they have both been done // These actions are async so we need to be sure that they have both been done
const serverRunString = { const serverRunString = {
'Server listening': false 'Server listening': false
@ -208,14 +213,15 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
env['NODE_APP_INSTANCE'] = server.internalServerNumber.toString() env['NODE_APP_INSTANCE'] = server.internalServerNumber.toString()
env['NODE_CONFIG'] = JSON.stringify(configOverride) env['NODE_CONFIG'] = JSON.stringify(configOverride)
const options = { const forkOptions = {
silent: true, silent: true,
env, env,
detached: true detached: true,
execArgv: options.execArgv || []
} }
return new Promise<ServerInfo>(res => { return new Promise<ServerInfo>(res => {
server.app = fork(join(root(), 'dist', 'server.js'), args, options) server.app = fork(join(root(), 'dist', 'server.js'), args, forkOptions)
server.app.stdout.on('data', function onStdout (data) { server.app.stdout.on('data', function onStdout (data) {
let dontContinue = false let dontContinue = false
@ -240,7 +246,7 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
// If no, there is maybe one thing not already initialized (client/user credentials generation...) // If no, there is maybe one thing not already initialized (client/user credentials generation...)
if (dontContinue === true) return if (dontContinue === true) return
if (silent === false) { if (options.hideLogs === false) {
console.log(data.toString()) console.log(data.toString())
} else { } else {
server.app.stdout.removeListener('data', onStdout) server.app.stdout.removeListener('data', onStdout)