Skip to content

Commit

Permalink
exec keep-alive
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonewu committed Dec 19, 2022
1 parent 91e289c commit 227c09c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ class SshTunnel {
if (!this.sshClient) {
await this.createSshClient();
}
const alive = await this.throttleCheckAlive();
if (!alive) {
logger.lightWhite('ssh connection was hung up, reconnecting...');
await this.createSshClient();
}
let res = '';
return new Promise((resolve, reject) => {
this.sshClient?.exec(command, (err, stream) => {
Expand Down Expand Up @@ -435,7 +440,7 @@ class SshTunnel {

/**
* @descrption close tunnel and destroy all the instance
* @params key: The server you want to close.If passing empty, it will close all the servers and the main ssh client.
* @params key: The server key you want to close.If passing empty, it will close all the servers and the main ssh client.
*/
public close = async (key?: string | number) => {
if (!key) {
Expand Down

0 comments on commit 227c09c

Please sign in to comment.