From d1687c153343a8d46ec77410b226b65f8e2da1ba Mon Sep 17 00:00:00 2001 From: Asher Date: Tue, 24 Mar 2020 17:37:34 -0500 Subject: [PATCH] Catch error when SSH server fails to start --- src/node/entry.ts | 6 +++++- src/node/ssh/server.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/node/entry.ts b/src/node/entry.ts index ac95ad14b..1a497a79d 100644 --- a/src/node/entry.ts +++ b/src/node/entry.ts @@ -73,7 +73,11 @@ const main = async (args: Args): Promise => { let sshPort = "" if (!args["disable-ssh"] && options.sshHostKey) { const sshProvider = httpServer.registerHttpProvider("/ssh", SshProvider, options.sshHostKey as string) - sshPort = await sshProvider.listen() + try { + sshPort = await sshProvider.listen() + } catch (error) { + logger.warn(`SSH server: ${error.message}`) + } } const serverAddress = await httpServer.listen() diff --git a/src/node/ssh/server.ts b/src/node/ssh/server.ts index c2e1ec17d..76a445795 100644 --- a/src/node/ssh/server.ts +++ b/src/node/ssh/server.ts @@ -20,7 +20,7 @@ export class SshProvider extends HttpProvider { this.sshServer = new ssh.Server({ hostKeys: [hostKey] }, this.handleSsh) this.sshServer.on("error", (err) => { - logger.error(`SSH server error: ${err.stack}`) + logger.trace(`SSH server error: ${err.stack}`) }) }