From ac97d3c05a6566577585101ff085927a4389aa05 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Wed, 8 Nov 2023 16:19:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=88=AB=E5=90=8D=E5=AF=BC=E8=87=B4=E6=97=A0=E6=B3=95=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=BC=80=E6=9C=BA=E8=87=AA=E5=90=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#2849)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/ssh.go | 6 ++++++ frontend/src/components/compose-log/index.vue | 2 +- frontend/src/components/container-log/index.vue | 2 +- frontend/src/views/container/container/log/index.vue | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/app/service/ssh.go b/backend/app/service/ssh.go index 2b26aea26..421785a04 100644 --- a/backend/app/service/ssh.go +++ b/backend/app/service/ssh.go @@ -109,6 +109,12 @@ func (u *SSHService) OperateSSH(operation string) error { } stdout, err := cmd.Execf("%s systemctl %s %s", sudo, operation, serviceName) if err != nil { + if strings.Contains(stdout, "alias name or linked unit file") { + stdout, err := cmd.Execf("%s systemctl %s ssh", sudo, operation) + if err != nil { + return fmt.Errorf("%s ssh(alias name or linked unit file) failed, stdout: %s, err: %v", operation, stdout, err) + } + } return fmt.Errorf("%s %s failed, stdout: %s, err: %v", operation, serviceName, stdout, err) } return nil diff --git a/frontend/src/components/compose-log/index.vue b/frontend/src/components/compose-log/index.vue index f8a54509a..1862c1387 100644 --- a/frontend/src/components/compose-log/index.vue +++ b/frontend/src/components/compose-log/index.vue @@ -86,7 +86,7 @@ const logSearch = reactive({ }); const handleClose = () => { - terminalSocket.value!.send('close conn'); + terminalSocket.value?.send('close conn'); open.value = false; }; diff --git a/frontend/src/components/container-log/index.vue b/frontend/src/components/container-log/index.vue index 488ee99f9..ea62755c4 100644 --- a/frontend/src/components/container-log/index.vue +++ b/frontend/src/components/container-log/index.vue @@ -155,7 +155,7 @@ const onClean = async () => { }; onBeforeUnmount(() => { - terminalSocket.value!.send('close conn'); + terminalSocket.value?.send('close conn'); }); defineExpose({ diff --git a/frontend/src/views/container/container/log/index.vue b/frontend/src/views/container/container/log/index.vue index e4afb6bb8..b3b979ec0 100644 --- a/frontend/src/views/container/container/log/index.vue +++ b/frontend/src/views/container/container/log/index.vue @@ -132,7 +132,7 @@ const loadTooltip = () => { return i18n.global.t('commons.button.' + (screenfull.isFullscreen ? 'quitFullscreen' : 'fullscreen')); }; const handleClose = async () => { - terminalSocket.value!.send('close conn'); + terminalSocket.value?.send('close conn'); logVisible.value = false; }; watch(logVisible, (val) => {