From e9f60a79075299dadf82a2a4478f9ae1d862f639 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 3 Aug 2020 16:45:59 +0300 Subject: [PATCH] fix Cmd+Q exit error Signed-off-by: Roman --- src/main/kube-auth-proxy.ts | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/main/kube-auth-proxy.ts b/src/main/kube-auth-proxy.ts index ea87eadfe9..0db75a8a67 100644 --- a/src/main/kube-auth-proxy.ts +++ b/src/main/kube-auth-proxy.ts @@ -34,8 +34,6 @@ export class KubeAuthProxy { const args = [ "proxy", "-p", `${this.port}`, - // "--kubeconfig", `"${this.cluster.kubeConfigPath}"`, - // "--context", `"${this.cluster.contextName}"`, "--kubeconfig", `${this.cluster.kubeConfigPath}`, "--context", `${this.cluster.contextName}`, "--accept-hosts", ".*", @@ -49,12 +47,9 @@ export class KubeAuthProxy { this.proxyProcess.on("exit", (code) => { this.sendIpcLogMessage({ data: `proxy exited with code: ${code}`, error: code > 0 }) - this.proxyProcess.removeAllListeners(); - this.proxyProcess.stderr.removeAllListeners(); - this.proxyProcess.stdout.removeAllListeners(); - this.proxyProcess = null; + this.exit(); }) - + this.proxyProcess.stdout.on('data', (data) => { let logItem = data.toString() if (logItem.startsWith("Starting to serve on")) { @@ -62,7 +57,7 @@ export class KubeAuthProxy { } this.sendIpcLogMessage({ data: logItem }) }) - + this.proxyProcess.stderr.on('data', (data) => { this.lastError = this.parseError(data.toString()) this.sendIpcLogMessage({ data: data.toString(), error: true }) @@ -97,10 +92,12 @@ export class KubeAuthProxy { } public exit() { - if (this.proxyProcess) { - logger.debug("[KUBE-AUTH]: stopping local proxy", this.cluster.getMeta()) - this.proxyProcess.kill() - this.proxyProcess = null; - } + if (!this.proxyProcess) return; + logger.debug("[KUBE-AUTH]: stopping local proxy", this.cluster.getMeta()) + this.proxyProcess.kill() + this.proxyProcess.removeAllListeners(); + this.proxyProcess.stderr.removeAllListeners(); + this.proxyProcess.stdout.removeAllListeners(); + this.proxyProcess = null; } }