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 @@
+
+ + + {{ $t('runtime.rebuild') }} + + + + + {{ $t('runtime.rebuildHelper') }} +
+
+
+
@@ -154,6 +167,7 @@ const runtime = ref({ params: {}, type: 'php', resource: 'appstore', + rebuild: false, }); const rules = ref({ name: [Rules.appName], @@ -256,20 +270,15 @@ const submit = async (formEl: FormInstance | undefined) => { loading.value = false; }); } else { - ElMessageBox.confirm(i18n.global.t('runtime.rebuildHelper'), i18n.global.t('commons.msg.infoTitle'), { - confirmButtonText: i18n.global.t('commons.button.confirm'), - cancelButtonText: i18n.global.t('commons.button.cancel'), - }).then(async () => { - loading.value = true; - UpdateRuntime(runtime.value) - .then(() => { - MsgSuccess(i18n.global.t('commons.msg.updateSuccess')); - handleClose(); - }) - .finally(() => { - loading.value = false; - }); - }); + loading.value = true; + UpdateRuntime(runtime.value) + .then(() => { + MsgSuccess(i18n.global.t('commons.msg.updateSuccess')); + handleClose(); + }) + .finally(() => { + loading.value = false; + }); } }); }; @@ -288,6 +297,7 @@ const getRuntime = async (id: number) => { resource: data.resource, appId: data.appId, version: data.version, + rebuild: true, }; editParams.value = data.appParams; if (mode.value == 'create') {