Catch error when SSH server fails to start

This commit is contained in:
Asher 2020-03-24 17:37:34 -05:00
parent f5f29c0120
commit d1687c1533
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
2 changed files with 6 additions and 2 deletions

View File

@ -73,7 +73,11 @@ const main = async (args: Args): Promise<void> => {
let sshPort = "" let sshPort = ""
if (!args["disable-ssh"] && options.sshHostKey) { if (!args["disable-ssh"] && options.sshHostKey) {
const sshProvider = httpServer.registerHttpProvider("/ssh", SshProvider, options.sshHostKey as string) const sshProvider = httpServer.registerHttpProvider("/ssh", SshProvider, options.sshHostKey as string)
try {
sshPort = await sshProvider.listen() sshPort = await sshProvider.listen()
} catch (error) {
logger.warn(`SSH server: ${error.message}`)
}
} }
const serverAddress = await httpServer.listen() const serverAddress = await httpServer.listen()

View File

@ -20,7 +20,7 @@ export class SshProvider extends HttpProvider {
this.sshServer = new ssh.Server({ hostKeys: [hostKey] }, this.handleSsh) this.sshServer = new ssh.Server({ hostKeys: [hostKey] }, this.handleSsh)
this.sshServer.on("error", (err) => { this.sshServer.on("error", (err) => {
logger.error(`SSH server error: ${err.stack}`) logger.trace(`SSH server error: ${err.stack}`)
}) })
} }