From bd2e2f11d09aa015125e5b5b05ca57a44b6f2d32 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 30 Nov 2020 14:47:54 +0100 Subject: Add inspect to test script --- shared/extra-utils/server/servers.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'shared/extra-utils/server') diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index 1126a7d93..4ad3eb14a 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts @@ -104,7 +104,12 @@ function randomRTMP () { 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 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 const serverRunString = { 'Server listening': false @@ -208,14 +213,15 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = [] env['NODE_APP_INSTANCE'] = server.internalServerNumber.toString() env['NODE_CONFIG'] = JSON.stringify(configOverride) - const options = { + const forkOptions = { silent: true, env, - detached: true + detached: true, + execArgv: options.execArgv || [] } return new Promise(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) { 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 (dontContinue === true) return - if (silent === false) { + if (options.hideLogs === false) { console.log(data.toString()) } else { server.app.stdout.removeListener('data', onStdout) -- cgit v1.2.3