mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-14 01:34:47 +08:00
feat: PHP 运行环境更新增加重建 php 应用功能 (#2095)
This commit is contained in:
parent
8b1098fc9d
commit
b55b930353
@ -29,4 +29,5 @@ type RuntimeUpdate struct {
|
|||||||
Params map[string]interface{} `json:"params"`
|
Params map[string]interface{} `json:"params"`
|
||||||
Image string `json:"image"`
|
Image string `json:"image"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
|
Rebuild bool `json:"rebuild"`
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ func (r *RuntimeService) Create(create request.RuntimeCreate) (err error) {
|
|||||||
if err = runtimeRepo.Create(context.Background(), runtime); err != nil {
|
if err = runtimeRepo.Create(context.Background(), runtime); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
go buildRuntime(runtime, "")
|
go buildRuntime(runtime, "", false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,6 +272,6 @@ func (r *RuntimeService) Update(req request.RuntimeUpdate) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
go buildRuntime(runtime, imageID)
|
go buildRuntime(runtime, imageID, req.Rebuild)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package service
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/model"
|
"github.com/1Panel-dev/1Panel/backend/app/model"
|
||||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||||
@ -17,7 +18,7 @@ import (
|
|||||||
"strings"
|
"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)
|
runtimePath := path.Join(constant.RuntimeDir, runtime.Type, runtime.Name)
|
||||||
composePath := path.Join(runtimePath, "docker-compose.yml")
|
composePath := path.Join(runtimePath, "docker-compose.yml")
|
||||||
logPath := path.Join(runtimePath, "build.log")
|
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)
|
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)
|
_ = runtimeRepo.Save(runtime)
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ export namespace Runtime {
|
|||||||
resource: string;
|
resource: string;
|
||||||
appId?: number;
|
appId?: number;
|
||||||
version?: string;
|
version?: string;
|
||||||
|
rebuild?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RuntimeUpdate {
|
export interface RuntimeUpdate {
|
||||||
@ -46,6 +47,7 @@ export namespace Runtime {
|
|||||||
resource: string;
|
resource: string;
|
||||||
appId?: number;
|
appId?: number;
|
||||||
version?: string;
|
version?: string;
|
||||||
|
rebuild?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RuntimeDelete {
|
export interface RuntimeDelete {
|
||||||
|
@ -1644,10 +1644,10 @@ const message = {
|
|||||||
edit: 'Edit runtime',
|
edit: 'Edit runtime',
|
||||||
extendHelper:
|
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,',
|
'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:
|
rebuildHelper: 'After editing the extension, you need to to rebuild the PHP application to take effect',
|
||||||
'After editing the extension, you need to go to the [App Store-Installed] page to rebuild the PHP application to take effect',
|
|
||||||
phpPluginHelper:
|
phpPluginHelper:
|
||||||
'<a target="_blank" href="https://1panel.cn/docs/user_manual/websites/php/#php_1">View PHP extension list</a> ',
|
'<a target="_blank" href="https://1panel.cn/docs/user_manual/websites/php/#php_1">View PHP extension list</a> ',
|
||||||
|
rebuild: 'Rebuild PHP App',
|
||||||
},
|
},
|
||||||
process: {
|
process: {
|
||||||
pid: 'Process ID',
|
pid: 'Process ID',
|
||||||
|
@ -1559,7 +1559,10 @@ const message = {
|
|||||||
toupgrade: '去升級',
|
toupgrade: '去升級',
|
||||||
edit: '編輯運行環境',
|
edit: '編輯運行環境',
|
||||||
extendHelper: '列表中不存在的擴展,可以手動輸入之後選擇,例:輸入 sockets ,然後在下拉列表中選擇第一個',
|
extendHelper: '列表中不存在的擴展,可以手動輸入之後選擇,例:輸入 sockets ,然後在下拉列表中選擇第一個',
|
||||||
rebuildHelper: '編輯擴展後需要去【應用商店-已安裝】頁面【重建】PHP 應用之後才能生效',
|
rebuildHelper: '編輯擴展後需要【重建】PHP 應用之後才能生效',
|
||||||
|
phpPluginHelper:
|
||||||
|
"<a target=“_blank” href='https://1panel.cn/docs/user_manual/websites/php/#php_1'>查看 PHP 擴展列表</a> ",
|
||||||
|
rebuild: '重建 PHP 應用',
|
||||||
},
|
},
|
||||||
process: {
|
process: {
|
||||||
pid: '進程ID',
|
pid: '進程ID',
|
||||||
|
@ -1559,9 +1559,10 @@ const message = {
|
|||||||
toupgrade: '去升级',
|
toupgrade: '去升级',
|
||||||
edit: '编辑运行环境',
|
edit: '编辑运行环境',
|
||||||
extendHelper: '列表中不存在的扩展,可以手动输入之后选择,例:输入 sockets ,然后在下拉列表中选择第一个,',
|
extendHelper: '列表中不存在的扩展,可以手动输入之后选择,例:输入 sockets ,然后在下拉列表中选择第一个,',
|
||||||
rebuildHelper: '编辑扩展后需要去【应用商店-已安装】页面【重建】PHP 应用之后才能生效',
|
rebuildHelper: '编辑扩展后需要【重建】PHP 应用之后才能生效',
|
||||||
phpPluginHelper:
|
phpPluginHelper:
|
||||||
"<a target=“_blank” href='https://1panel.cn/docs/user_manual/websites/php/#php_1'>查看 PHP 扩展列表</a> ",
|
"<a target=“_blank” href='https://1panel.cn/docs/user_manual/websites/php/#php_1'>查看 PHP 扩展列表</a> ",
|
||||||
|
rebuild: '重建 PHP 应用',
|
||||||
},
|
},
|
||||||
process: {
|
process: {
|
||||||
pid: '进程ID',
|
pid: '进程ID',
|
||||||
|
@ -89,6 +89,19 @@
|
|||||||
<br />
|
<br />
|
||||||
</el-alert>
|
</el-alert>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<div v-if="runtime.type === 'php' && mode == 'edit'">
|
||||||
|
<el-form-item>
|
||||||
|
<el-checkbox v-model="runtime.rebuild">
|
||||||
|
{{ $t('runtime.rebuild') }}
|
||||||
|
</el-checkbox>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-alert type="info" :closable="false">
|
||||||
|
<span>{{ $t('runtime.rebuildHelper') }}</span>
|
||||||
|
<br />
|
||||||
|
</el-alert>
|
||||||
|
</el-form-item>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
@ -154,6 +167,7 @@ const runtime = ref<Runtime.RuntimeCreate>({
|
|||||||
params: {},
|
params: {},
|
||||||
type: 'php',
|
type: 'php',
|
||||||
resource: 'appstore',
|
resource: 'appstore',
|
||||||
|
rebuild: false,
|
||||||
});
|
});
|
||||||
const rules = ref<any>({
|
const rules = ref<any>({
|
||||||
name: [Rules.appName],
|
name: [Rules.appName],
|
||||||
@ -256,20 +270,15 @@ const submit = async (formEl: FormInstance | undefined) => {
|
|||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
ElMessageBox.confirm(i18n.global.t('runtime.rebuildHelper'), i18n.global.t('commons.msg.infoTitle'), {
|
loading.value = true;
|
||||||
confirmButtonText: i18n.global.t('commons.button.confirm'),
|
UpdateRuntime(runtime.value)
|
||||||
cancelButtonText: i18n.global.t('commons.button.cancel'),
|
.then(() => {
|
||||||
}).then(async () => {
|
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
|
||||||
loading.value = true;
|
handleClose();
|
||||||
UpdateRuntime(runtime.value)
|
})
|
||||||
.then(() => {
|
.finally(() => {
|
||||||
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
|
loading.value = false;
|
||||||
handleClose();
|
});
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
loading.value = false;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -288,6 +297,7 @@ const getRuntime = async (id: number) => {
|
|||||||
resource: data.resource,
|
resource: data.resource,
|
||||||
appId: data.appId,
|
appId: data.appId,
|
||||||
version: data.version,
|
version: data.version,
|
||||||
|
rebuild: true,
|
||||||
};
|
};
|
||||||
editParams.value = data.appParams;
|
editParams.value = data.appParams;
|
||||||
if (mode.value == 'create') {
|
if (mode.value == 'create') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user