aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-07 15:20:03 +0100
committerChocobozzz <me@florianbigard.com>2021-12-07 15:20:03 +0100
commitf307255e694d290c346749bff68545d5dfc581cf (patch)
tree49180988673ce49b9e5bd8eed57a389e7f3eb0a5 /shared/extra-utils/server
parent636d73c58866ed235c207719e41fdde3c2d6c969 (diff)
downloadPeerTube-f307255e694d290c346749bff68545d5dfc581cf.tar.gz
PeerTube-f307255e694d290c346749bff68545d5dfc581cf.tar.zst
PeerTube-f307255e694d290c346749bff68545d5dfc581cf.zip
Display server logs when server run fails
Diffstat (limited to 'shared/extra-utils/server')
-rw-r--r--shared/extra-utils/server/server.ts12
1 files changed, 8 insertions, 4 deletions
diff --git a/shared/extra-utils/server/server.ts b/shared/extra-utils/server/server.ts
index 31224ebe9..9da293877 100644
--- a/shared/extra-utils/server/server.ts
+++ b/shared/extra-utils/server/server.ts
@@ -220,10 +220,11 @@ export class PeerTubeServer {
220 220
221 return new Promise<void>((res, rej) => { 221 return new Promise<void>((res, rej) => {
222 const self = this 222 const self = this
223 let aggregatedLogs = ''
223 224
224 this.app = fork(join(root(), 'dist', 'server.js'), options.peertubeArgs || [], forkOptions) 225 this.app = fork(join(root(), 'dist', 'server.js'), options.peertubeArgs || [], forkOptions)
225 226
226 const onPeerTubeExit = () => rej(new Error('Process exited')) 227 const onPeerTubeExit = () => rej(new Error('Process exited:\n' + aggregatedLogs))
227 const onParentExit = () => { 228 const onParentExit = () => {
228 if (!this.app || !this.app.pid) return 229 if (!this.app || !this.app.pid) return
229 230
@@ -238,10 +239,13 @@ export class PeerTubeServer {
238 this.app.stdout.on('data', function onStdout (data) { 239 this.app.stdout.on('data', function onStdout (data) {
239 let dontContinue = false 240 let dontContinue = false
240 241
242 const log: string = data.toString()
243 aggregatedLogs += log
244
241 // Capture things if we want to 245 // Capture things if we want to
242 for (const key of Object.keys(regexps)) { 246 for (const key of Object.keys(regexps)) {
243 const regexp = regexps[key] 247 const regexp = regexps[key]
244 const matches = data.toString().match(regexp) 248 const matches = log.match(regexp)
245 if (matches !== null) { 249 if (matches !== null) {
246 if (key === 'client_id') self.store.client.id = matches[1] 250 if (key === 'client_id') self.store.client.id = matches[1]
247 else if (key === 'client_secret') self.store.client.secret = matches[1] 251 else if (key === 'client_secret') self.store.client.secret = matches[1]
@@ -252,7 +256,7 @@ export class PeerTubeServer {
252 256
253 // Check if all required sentences are here 257 // Check if all required sentences are here
254 for (const key of Object.keys(serverRunString)) { 258 for (const key of Object.keys(serverRunString)) {
255 if (data.toString().indexOf(key) !== -1) serverRunString[key] = true 259 if (log.includes(key)) serverRunString[key] = true
256 if (serverRunString[key] === false) dontContinue = true 260 if (serverRunString[key] === false) dontContinue = true
257 } 261 }
258 262
@@ -260,7 +264,7 @@ export class PeerTubeServer {
260 if (dontContinue === true) return 264 if (dontContinue === true) return
261 265
262 if (options.hideLogs === false) { 266 if (options.hideLogs === false) {
263 console.log(data.toString()) 267 console.log(log)
264 } else { 268 } else {
265 process.removeListener('exit', onParentExit) 269 process.removeListener('exit', onParentExit)
266 self.app.stdout.removeListener('data', onStdout) 270 self.app.stdout.removeListener('data', onStdout)