mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-28 05:15:04 +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"`
|
||||
Image string `json:"image"`
|
||||
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 {
|
||||
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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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:
|
||||
'<a target="_blank" href="https://1panel.cn/docs/user_manual/websites/php/#php_1">View PHP extension list</a> ',
|
||||
rebuild: 'Rebuild PHP App',
|
||||
},
|
||||
process: {
|
||||
pid: 'Process ID',
|
||||
|
@ -1559,7 +1559,10 @@ const message = {
|
||||
toupgrade: '去升級',
|
||||
edit: '編輯運行環境',
|
||||
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: {
|
||||
pid: '進程ID',
|
||||
|
@ -1559,9 +1559,10 @@ const message = {
|
||||
toupgrade: '去升级',
|
||||
edit: '编辑运行环境',
|
||||
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: {
|
||||
pid: '进程ID',
|
||||
|
@ -89,6 +89,19 @@
|
||||
<br />
|
||||
</el-alert>
|
||||
</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 v-else>
|
||||
@ -154,6 +167,7 @@ const runtime = ref<Runtime.RuntimeCreate>({
|
||||
params: {},
|
||||
type: 'php',
|
||||
resource: 'appstore',
|
||||
rebuild: false,
|
||||
});
|
||||
const rules = ref<any>({
|
||||
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') {
|
||||
|
Loading…
Reference in New Issue
Block a user