From 47b75673f986527729fcf4e0167e9f08e69f996d Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Thu, 2 Nov 2023 14:35:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A4=84=E7=90=86=201Panel=20=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E5=AF=BC=E8=87=B4=E8=BF=90=E8=A1=8C=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#2773)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/runtime.go | 16 ++++++++++++++++ backend/constant/common.go | 2 ++ backend/init/business/business.go | 7 +++++++ backend/utils/ssl/acme_test.go | 2 +- frontend/src/lang/modules/en.ts | 2 ++ frontend/src/lang/modules/tw.ts | 2 ++ frontend/src/lang/modules/zh.ts | 2 ++ frontend/src/views/website/runtime/php/index.vue | 9 ++++++++- 8 files changed, 40 insertions(+), 2 deletions(-) diff --git a/backend/app/service/runtime.go b/backend/app/service/runtime.go index 61c36b7a8..dc2636c13 100644 --- a/backend/app/service/runtime.go +++ b/backend/app/service/runtime.go @@ -40,6 +40,7 @@ type IRuntimeService interface { OperateRuntime(req request.RuntimeOperate) error GetNodeModules(req request.NodeModuleReq) ([]response.NodeModule, error) OperateNodeModules(req request.NodeModuleOperateReq) error + SyncForRestart() error } func NewRuntimeService() IRuntimeService { @@ -555,3 +556,18 @@ func (r *RuntimeService) OperateNodeModules(req request.NodeModuleOperateReq) er cmd += " " + req.Module return cmd2.ExecContainerScript(containerName, cmd, 5*time.Minute) } + +func (r *RuntimeService) SyncForRestart() error { + runtimes, err := runtimeRepo.List() + if err != nil { + return err + } + for _, runtime := range runtimes { + if runtime.Status == constant.RuntimeBuildIng || runtime.Status == constant.RuntimeReCreating || runtime.Status == constant.RuntimeStarting || runtime.Status == constant.RuntimeCreating { + runtime.Status = constant.SystemRestart + runtime.Message = "System restart causing interrupt" + _ = runtimeRepo.Save(&runtime) + } + } + return nil +} diff --git a/backend/constant/common.go b/backend/constant/common.go index 4488f1ffe..9b3e312fb 100644 --- a/backend/constant/common.go +++ b/backend/constant/common.go @@ -4,4 +4,6 @@ type DBContext string const ( DB DBContext = "db" + + SystemRestart = "systemRestart" ) diff --git a/backend/init/business/business.go b/backend/init/business/business.go index be9a1ed8d..f92b672d0 100644 --- a/backend/init/business/business.go +++ b/backend/init/business/business.go @@ -8,6 +8,7 @@ import ( func Init() { go syncApp() go syncInstalledApp() + go syncRuntime() } func syncApp() { @@ -22,3 +23,9 @@ func syncInstalledApp() { global.LOG.Errorf("sync instaled app error: %s", err.Error()) } } + +func syncRuntime() { + if err := service.NewRuntimeService().SyncForRestart(); err != nil { + global.LOG.Errorf("sync runtime status error : %s", err.Error()) + } +} diff --git a/backend/utils/ssl/acme_test.go b/backend/utils/ssl/acme_test.go index 231a2441f..93caecd26 100644 --- a/backend/utils/ssl/acme_test.go +++ b/backend/utils/ssl/acme_test.go @@ -144,7 +144,7 @@ func TestAppToV2(t *testing.T) { } _ = fileOp.DeleteFile(newVersionDir + "/config.json") oldReadMefile := newVersionDir + "/README.md" - // _ = fileOp.Cut([]string{oldReadMefile}, newAppDir) + _ = fileOp.Cut([]string{oldReadMefile}, newAppDir, "", false) _ = fileOp.DeleteFile(oldReadMefile) } } diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 43b419f0f..807d73896 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -234,6 +234,7 @@ const message = { starting: 'Starting', recreating: 'Recreating', creating: 'Creating', + systemrestart: 'Interrupt', }, units: { second: 'Second', @@ -1842,6 +1843,7 @@ const message = { customScript: 'Custom startup command', customScriptHelper: 'Please fill in the complete startup command, for example: npm run start', portError: 'Cannot fill in the same port', + systemRestartHelper: 'Status description: Interruption - status acquisition failed due to system restart', }, process: { pid: 'Process ID', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index a4a14ce72..62fd953e5 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -233,6 +233,7 @@ const message = { starting: '啟動中', recreating: '重建中', creating: '創建中', + systemrestart: '中斷', }, units: { second: '秒', @@ -1738,6 +1739,7 @@ const message = { customScript: '自訂啟動指令', customScriptHelper: '請填寫完整的啟動指令,例如:npm run start', portError: '不能填寫相同連接埠', + systemRestartHelper: '狀態說明:中斷-系統重新啟動導致狀態取得失敗', }, process: { pid: '進程ID', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index f834dbd49..c4e489743 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -233,6 +233,7 @@ const message = { starting: '启动中', recreating: '重建中', creating: '创建中', + systemrestart: '中断', }, units: { second: '秒', @@ -1738,6 +1739,7 @@ const message = { customScript: '自定义启动命令', customScriptHelper: '请填写完整的启动命令,例如:npm run start', portError: '不能填写相同端口', + systemRestartHelper: '状态说明:中断-系统重启导致状态获取失败', }, process: { pid: '进程ID', diff --git a/frontend/src/views/website/runtime/php/index.vue b/frontend/src/views/website/runtime/php/index.vue index 4e19d79d1..46873e29d 100644 --- a/frontend/src/views/website/runtime/php/index.vue +++ b/frontend/src/views/website/runtime/php/index.vue @@ -2,6 +2,13 @@