From b55b9303534f59d0339fa37f5c1a888b06558b28 Mon Sep 17 00:00:00 2001
From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com>
Date: Mon, 28 Aug 2023 22:18:15 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20PHP=20=E8=BF=90=E8=A1=8C=E7=8E=AF?=
=?UTF-8?q?=E5=A2=83=E6=9B=B4=E6=96=B0=E5=A2=9E=E5=8A=A0=E9=87=8D=E5=BB=BA?=
=?UTF-8?q?=20php=20=E5=BA=94=E7=94=A8=E5=8A=9F=E8=83=BD=20(#2095)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
backend/app/dto/request/runtime.go | 1 +
backend/app/service/runtime.go | 4 +-
backend/app/service/runtime_utils.go | 26 ++++++++++++-
frontend/src/api/interface/runtime.ts | 2 +
frontend/src/lang/modules/en.ts | 4 +-
frontend/src/lang/modules/tw.ts | 5 ++-
frontend/src/lang/modules/zh.ts | 3 +-
.../views/website/runtime/create/index.vue | 38 ++++++++++++-------
8 files changed, 62 insertions(+), 21 deletions(-)
diff --git a/backend/app/dto/request/runtime.go b/backend/app/dto/request/runtime.go
index 96b838453..187937dc9 100644
--- a/backend/app/dto/request/runtime.go
+++ b/backend/app/dto/request/runtime.go
@@ -29,4 +29,5 @@ type RuntimeUpdate struct {
Params map[string]interface{} `json:"params"`
Image string `json:"image"`
Version string `json:"version"`
+ Rebuild bool `json:"rebuild"`
}
diff --git a/backend/app/service/runtime.go b/backend/app/service/runtime.go
index dbf37f76e..411a97f8e 100644
--- a/backend/app/service/runtime.go
+++ b/backend/app/service/runtime.go
@@ -113,7 +113,7 @@ func (r *RuntimeService) Create(create request.RuntimeCreate) (err error) {
if err = runtimeRepo.Create(context.Background(), runtime); err != nil {
return
}
- go buildRuntime(runtime, "")
+ go buildRuntime(runtime, "", false)
return
}
@@ -272,6 +272,6 @@ func (r *RuntimeService) Update(req request.RuntimeUpdate) error {
if err != nil {
return err
}
- go buildRuntime(runtime, imageID)
+ go buildRuntime(runtime, imageID, req.Rebuild)
return nil
}
diff --git a/backend/app/service/runtime_utils.go b/backend/app/service/runtime_utils.go
index 7b9244dcf..a36988cf3 100644
--- a/backend/app/service/runtime_utils.go
+++ b/backend/app/service/runtime_utils.go
@@ -3,6 +3,7 @@ package service
import (
"bytes"
"fmt"
+ "github.com/1Panel-dev/1Panel/backend/app/dto/request"
"github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/backend/buserr"
"github.com/1Panel-dev/1Panel/backend/constant"
@@ -17,7 +18,7 @@ import (
"strings"
)
-func buildRuntime(runtime *model.Runtime, oldImageID string) {
+func buildRuntime(runtime *model.Runtime, oldImageID string, rebuild bool) {
runtimePath := path.Join(constant.RuntimeDir, runtime.Type, runtime.Name)
composePath := path.Join(runtimePath, "docker-compose.yml")
logPath := path.Join(runtimePath, "build.log")
@@ -61,6 +62,29 @@ func buildRuntime(runtime *model.Runtime, oldImageID string) {
global.LOG.Errorf("delete imageID [%s] error %v", oldImageID, err)
}
}
+ if rebuild && runtime.ID > 0 {
+ websites, _ := websiteRepo.GetBy(websiteRepo.WithRuntimeID(runtime.ID))
+ if len(websites) > 0 {
+ installService := NewIAppInstalledService()
+ installMap := make(map[uint]string)
+ for _, website := range websites {
+ if website.AppInstallID > 0 {
+ installMap[website.AppInstallID] = website.PrimaryDomain
+ }
+ }
+ for installID, domain := range installMap {
+ go func(installID uint, domain string) {
+ global.LOG.Infof("rebuild php runtime [%s] domain [%s]", runtime.Name, domain)
+ if err := installService.Operate(request.AppInstalledOperate{
+ InstallId: installID,
+ Operate: constant.Rebuild,
+ }); err != nil {
+ global.LOG.Errorf("rebuild php runtime [%s] domain [%s] error %v", runtime.Name, domain, err)
+ }
+ }(installID, domain)
+ }
+ }
+ }
}
_ = runtimeRepo.Save(runtime)
}
diff --git a/frontend/src/api/interface/runtime.ts b/frontend/src/api/interface/runtime.ts
index 209cc45a9..f78aa431b 100644
--- a/frontend/src/api/interface/runtime.ts
+++ b/frontend/src/api/interface/runtime.ts
@@ -35,6 +35,7 @@ export namespace Runtime {
resource: string;
appId?: number;
version?: string;
+ rebuild?: boolean;
}
export interface RuntimeUpdate {
@@ -46,6 +47,7 @@ export namespace Runtime {
resource: string;
appId?: number;
version?: string;
+ rebuild?: boolean;
}
export interface RuntimeDelete {
diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts
index c809e9893..94d105618 100644
--- a/frontend/src/lang/modules/en.ts
+++ b/frontend/src/lang/modules/en.ts
@@ -1644,10 +1644,10 @@ const message = {
edit: 'Edit runtime',
extendHelper:
'Extensions that do not exist in the list can be selected after manual input, for example: input sockets, and then select the first one in the drop-down list,',
- rebuildHelper:
- 'After editing the extension, you need to go to the [App Store-Installed] page to rebuild the PHP application to take effect',
+ rebuildHelper: 'After editing the extension, you need to to rebuild the PHP application to take effect',
phpPluginHelper:
'View PHP extension list ',
+ rebuild: 'Rebuild PHP App',
},
process: {
pid: 'Process ID',
diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts
index 1ba77c4db..80ffd370b 100644
--- a/frontend/src/lang/modules/tw.ts
+++ b/frontend/src/lang/modules/tw.ts
@@ -1559,7 +1559,10 @@ const message = {
toupgrade: '去升級',
edit: '編輯運行環境',
extendHelper: '列表中不存在的擴展,可以手動輸入之後選擇,例:輸入 sockets ,然後在下拉列表中選擇第一個',
- rebuildHelper: '編輯擴展後需要去【應用商店-已安裝】頁面【重建】PHP 應用之後才能生效',
+ rebuildHelper: '編輯擴展後需要【重建】PHP 應用之後才能生效',
+ phpPluginHelper:
+ "查看 PHP 擴展列表 ",
+ rebuild: '重建 PHP 應用',
},
process: {
pid: '進程ID',
diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts
index ab640affb..9d3ea8590 100644
--- a/frontend/src/lang/modules/zh.ts
+++ b/frontend/src/lang/modules/zh.ts
@@ -1559,9 +1559,10 @@ const message = {
toupgrade: '去升级',
edit: '编辑运行环境',
extendHelper: '列表中不存在的扩展,可以手动输入之后选择,例:输入 sockets ,然后在下拉列表中选择第一个,',
- rebuildHelper: '编辑扩展后需要去【应用商店-已安装】页面【重建】PHP 应用之后才能生效',
+ rebuildHelper: '编辑扩展后需要【重建】PHP 应用之后才能生效',
phpPluginHelper:
"查看 PHP 扩展列表 ",
+ rebuild: '重建 PHP 应用',
},
process: {
pid: '进程ID',
diff --git a/frontend/src/views/website/runtime/create/index.vue b/frontend/src/views/website/runtime/create/index.vue
index 12e73b581..b92f1738c 100644
--- a/frontend/src/views/website/runtime/create/index.vue
+++ b/frontend/src/views/website/runtime/create/index.vue
@@ -89,6 +89,19 @@
+