From c702457a256c09e194bf3715f44b0fd3b2c6e06c Mon Sep 17 00:00:00 2001 From: Henry Wong Date: Fri, 1 Mar 2019 18:08:38 +0800 Subject: [PATCH] [Code] Adjust `GoLauncher` to adapt to the running pattern of go server. This adjust will let the code plugin connect the go-langserver actively. It should be noted that the `GoLauncher` is a semi-manufacture only support the detach mode for now. --- x-pack/plugins/code/server/lsp/go_launcher.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/code/server/lsp/go_launcher.ts b/x-pack/plugins/code/server/lsp/go_launcher.ts index e0b1f1693563d1..11b176ee5f87f1 100644 --- a/x-pack/plugins/code/server/lsp/go_launcher.ts +++ b/x-pack/plugins/code/server/lsp/go_launcher.ts @@ -27,23 +27,21 @@ export class GoLauncher implements ILanguageServerLauncher { const log = this.loggerFactory.getLogger(['code', `go@${this.targetHost}:${port}`]); const proxy = new LanguageServerProxy(port, this.targetHost, log); - proxy.awaitServerConnection(); - // detach mode + + log.info('Detach mode, expected langserver launch externally'); proxy.onConnected(() => { this.isRunning = true; }); proxy.onDisconnected(() => { this.isRunning = false; if (!proxy.isClosed) { - proxy.awaitServerConnection(); + log.warn('language server disconnected, reconnecting'); + setTimeout(() => proxy.connect(), 1000); } }); proxy.listen(); - return new Promise(resolve => { - proxy.onConnected(() => { - resolve(new RequestExpander(proxy, builtinWorkspace, maxWorkspace, this.options)); - }); - }); + await proxy.connect(); + return new RequestExpander(proxy, builtinWorkspace, maxWorkspace, this.options); } }