@milaboratories/pl-deployments 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/ssh/ssh.ts CHANGED
@@ -6,7 +6,11 @@ import fs from 'fs';
6
6
  import { readFile } from 'fs/promises';
7
7
  import upath from 'upath';
8
8
  import type { MiLogger } from '@milaboratories/ts-helpers';
9
- import { fileExists } from '@milaboratories/ts-helpers';
9
+
10
+ const defaultConfig: ConnectConfig = {
11
+ keepaliveInterval: 60000,
12
+ keepaliveCountMax: 10,
13
+ }
10
14
 
11
15
  export type SshAuthMethods = 'publickey' | 'password';
12
16
  export type SshAuthMethodsResult = SshAuthMethods[];
@@ -26,8 +30,13 @@ export class SshClient {
26
30
  * @returns A new instance of SshClient with an active connection.
27
31
  */
28
32
  public static async init(logger: MiLogger, config: ConnectConfig): Promise<SshClient> {
33
+ const withDefaults = {
34
+ ...defaultConfig,
35
+ ...config
36
+ };
37
+
29
38
  const client = new SshClient(logger, new Client());
30
- await client.connect(config);
39
+ await client.connect(withDefaults);
31
40
 
32
41
  return client;
33
42
  }
@@ -178,13 +187,13 @@ export class SshClient {
178
187
  });
179
188
 
180
189
  conn.on('error', (err) => {
181
- console.error('[SSH] SSH connection error', 'ports', ports, err.message);
190
+ this.logger.error(`[SSH] SSH connection error, ports: ${JSON.stringify(ports)}, err: ${err.message}`);
182
191
  server?.close();
183
192
  reject(`ssh.forwardPort: conn.err: ${err}`);
184
193
  });
185
194
 
186
195
  conn.on('close', () => {
187
- this.logger.info(`[SSH] Connection closed, ports: ${ports}`);
196
+ this.logger.info(`[SSH] Connection closed, ports: ${JSON.stringify(ports)}`);
188
197
  });
189
198
 
190
199
  conn.connect(config);