From 08642a765ea514a00f159db898edf14c376fbe6c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 10:20:44 +0200 Subject: Fix server run --- shared/extra-utils/server/server.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'shared') diff --git a/shared/extra-utils/server/server.ts b/shared/extra-utils/server/server.ts index b1347661f..cc6df2efe 100644 --- a/shared/extra-utils/server/server.ts +++ b/shared/extra-utils/server/server.ts @@ -219,6 +219,8 @@ export class PeerTubeServer { } return new Promise(res => { + const self = this + this.app = fork(join(root(), 'dist', 'server.js'), args, forkOptions) this.app.stdout.on('data', function onStdout (data) { let dontContinue = false @@ -228,10 +230,10 @@ export class PeerTubeServer { const regexp = regexps[key] const matches = data.toString().match(regexp) if (matches !== null) { - if (key === 'client_id') this.store.client.id = matches[1] - else if (key === 'client_secret') this.store.client.secret = matches[1] - else if (key === 'user_username') this.store.user.username = matches[1] - else if (key === 'user_password') this.store.user.password = matches[1] + if (key === 'client_id') self.store.client.id = matches[1] + else if (key === 'client_secret') self.store.client.secret = matches[1] + else if (key === 'user_username') self.store.user.username = matches[1] + else if (key === 'user_password') self.store.user.password = matches[1] } } @@ -247,12 +249,12 @@ export class PeerTubeServer { if (options.hideLogs === false) { console.log(data.toString()) } else { - this.app.stdout.removeListener('data', onStdout) + self.app.stdout.removeListener('data', onStdout) } process.on('exit', () => { try { - process.kill(this.server.app.pid) + process.kill(self.server.app.pid) } catch { /* empty */ } }) -- cgit v1.2.3