aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-30 14:47:54 +0100
committerChocobozzz <me@florianbigard.com>2020-11-30 15:06:25 +0100
commitbd2e2f11d09aa015125e5b5b05ca57a44b6f2d32 (patch)
tree07a63edc60be10d471cc95bb23ad5ce89c7fd5f5 /shared
parentf45c7cc770963670b3f2f1ac11d3ee3afc84a7ec (diff)
downloadPeerTube-bd2e2f11d09aa015125e5b5b05ca57a44b6f2d32.tar.gz
PeerTube-bd2e2f11d09aa015125e5b5b05ca57a44b6f2d32.tar.zst
PeerTube-bd2e2f11d09aa015125e5b5b05ca57a44b6f2d32.zip
Add inspect to test script
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/server/servers.ts20
1 files changed, 13 insertions, 7 deletions
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
107async function flushAndRunServer (serverNumber: number, configOverride?: Object, args = [], silent = true) { 107type RunServerOptions = {
108 hideLogs?: boolean
109 execArgv?: string[]
110}
111
112async 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
139async function runServer (server: ServerInfo, configOverrideArg?: any, args = [], silent?: boolean) { 144async 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)