diff options
-rw-r--r-- | server/tools/test.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/server/servers.ts | 20 |
2 files changed, 14 insertions, 8 deletions
diff --git a/server/tools/test.ts b/server/tools/test.ts index 23bf0120f..fc7f8d769 100644 --- a/server/tools/test.ts +++ b/server/tools/test.ts | |||
@@ -39,7 +39,7 @@ async function run () { | |||
39 | 39 | ||
40 | console.log('Starting server.') | 40 | console.log('Starting server.') |
41 | 41 | ||
42 | const server = await flushAndRunServer(1, {}, [], false) | 42 | const server = await flushAndRunServer(1, {}, [], { hideLogs: false, execArgv: [ '--inspect' ] }) |
43 | 43 | ||
44 | const cleanup = () => { | 44 | const cleanup = () => { |
45 | console.log('Killing server') | 45 | console.log('Killing 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 () { | |||
104 | return randomInt(low, high) | 104 | return randomInt(low, high) |
105 | } | 105 | } |
106 | 106 | ||
107 | async function flushAndRunServer (serverNumber: number, configOverride?: Object, args = [], silent = true) { | 107 | type RunServerOptions = { |
108 | hideLogs?: boolean | ||
109 | execArgv?: string[] | ||
110 | } | ||
111 | |||
112 | async function flushAndRunServer (serverNumber: number, configOverride?: Object, args = [], options: RunServerOptions = {}) { | ||
108 | const parallel = parallelTests() | 113 | const parallel = parallelTests() |
109 | 114 | ||
110 | const internalServerNumber = parallel ? randomServer() : serverNumber | 115 | const internalServerNumber = parallel ? randomServer() : serverNumber |
@@ -133,10 +138,10 @@ async function flushAndRunServer (serverNumber: number, configOverride?: Object, | |||
133 | } | 138 | } |
134 | } | 139 | } |
135 | 140 | ||
136 | return runServer(server, configOverride, args, silent) | 141 | return runServer(server, configOverride, args, options) |
137 | } | 142 | } |
138 | 143 | ||
139 | async function runServer (server: ServerInfo, configOverrideArg?: any, args = [], silent?: boolean) { | 144 | async function runServer (server: ServerInfo, configOverrideArg?: any, args = [], options: RunServerOptions = {}) { |
140 | // These actions are async so we need to be sure that they have both been done | 145 | // These actions are async so we need to be sure that they have both been done |
141 | const serverRunString = { | 146 | const serverRunString = { |
142 | 'Server listening': false | 147 | 'Server listening': false |
@@ -208,14 +213,15 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = [] | |||
208 | env['NODE_APP_INSTANCE'] = server.internalServerNumber.toString() | 213 | env['NODE_APP_INSTANCE'] = server.internalServerNumber.toString() |
209 | env['NODE_CONFIG'] = JSON.stringify(configOverride) | 214 | env['NODE_CONFIG'] = JSON.stringify(configOverride) |
210 | 215 | ||
211 | const options = { | 216 | const forkOptions = { |
212 | silent: true, | 217 | silent: true, |
213 | env, | 218 | env, |
214 | detached: true | 219 | detached: true, |
220 | execArgv: options.execArgv || [] | ||
215 | } | 221 | } |
216 | 222 | ||
217 | return new Promise<ServerInfo>(res => { | 223 | return new Promise<ServerInfo>(res => { |
218 | server.app = fork(join(root(), 'dist', 'server.js'), args, options) | 224 | server.app = fork(join(root(), 'dist', 'server.js'), args, forkOptions) |
219 | server.app.stdout.on('data', function onStdout (data) { | 225 | server.app.stdout.on('data', function onStdout (data) { |
220 | let dontContinue = false | 226 | let dontContinue = false |
221 | 227 | ||
@@ -240,7 +246,7 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = [] | |||
240 | // If no, there is maybe one thing not already initialized (client/user credentials generation...) | 246 | // If no, there is maybe one thing not already initialized (client/user credentials generation...) |
241 | if (dontContinue === true) return | 247 | if (dontContinue === true) return |
242 | 248 | ||
243 | if (silent === false) { | 249 | if (options.hideLogs === false) { |
244 | console.log(data.toString()) | 250 | console.log(data.toString()) |
245 | } else { | 251 | } else { |
246 | server.app.stdout.removeListener('data', onStdout) | 252 | server.app.stdout.removeListener('data', onStdout) |