From 3849b52cdf9fbbebfc8142146449079f703234c5 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Tue, 25 Jun 2024 12:28:37 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20ssh=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/certd-server/src/plugins/plugin-host/lib/ssh.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/ui/certd-server/src/plugins/plugin-host/lib/ssh.ts b/packages/ui/certd-server/src/plugins/plugin-host/lib/ssh.ts index d43caed0..53eb1ddb 100644 --- a/packages/ui/certd-server/src/plugins/plugin-host/lib/ssh.ts +++ b/packages/ui/certd-server/src/plugins/plugin-host/lib/ssh.ts @@ -31,6 +31,7 @@ export class AsyncSsh2Client { } async getSftp() { return new Promise((resolve, reject) => { + this.logger.info('获取sftp'); this.conn.sftp((err: any, sftp: any) => { if (err) { reject(err); @@ -44,6 +45,7 @@ export class AsyncSsh2Client { async fastPut(options: { sftp: any; localPath: string; remotePath: string }) { const { sftp, localPath, remotePath } = options; return new Promise((resolve, reject) => { + this.logger.info(`上传文件:${localPath} => ${remotePath}`); sftp.fastPut(localPath, remotePath, (err: Error) => { if (err) { reject(err); @@ -56,6 +58,7 @@ export class AsyncSsh2Client { async exec(script: string) { return new Promise((resolve, reject) => { + this.logger.info(`执行脚本:[${this.connConf.host}][exec]: ` + script); this.conn.exec(script, (err: Error, stream: any) => { if (err) { reject(err); @@ -84,8 +87,11 @@ export class AsyncSsh2Client { }); } - async shell(script: string): Promise { + async shell(script: string | string[]): Promise { return new Promise((resolve, reject) => { + this.logger.info( + `执行shell脚本:[${this.connConf.host}][shell]: ` + script + ); this.conn.shell((err: Error, stream: any) => { if (err) { reject(err);