mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 14:08:06 +08:00
feat(appstore): Handle Website Directory During Second Installation of OpenResty (#7649)
This commit is contained in:
parent
dc020499b8
commit
b1adafec2d
@ -804,3 +804,13 @@ func (b *BaseApi) BatchChangeModeAndOwner(c *gin.Context) {
|
||||
}
|
||||
helper.SuccessWithOutData(c)
|
||||
}
|
||||
|
||||
func (b *BaseApi) GetPathByType(c *gin.Context) {
|
||||
pathType, ok := c.Params.Get("type")
|
||||
if !ok {
|
||||
helper.BadRequest(c, errors.New("error pathType id in path"))
|
||||
return
|
||||
}
|
||||
resPath := fileService.GetPathByType(pathType)
|
||||
helper.SuccessWithData(c, resPath)
|
||||
}
|
||||
|
@ -31,19 +31,6 @@ func (i *AppInstall) GetPath() string {
|
||||
return path.Join(i.GetAppPath(), i.Name)
|
||||
}
|
||||
|
||||
//func (i *AppInstall) GetSiteDir() string {
|
||||
// var data map[string]interface{}
|
||||
// err := json.Unmarshal([]byte(i.Env), &data)
|
||||
// if err != nil {
|
||||
// return path.Join(i.GetAppPath(), i.Name, "www")
|
||||
// }
|
||||
// websiteDir, ok := data["WEBSITE_DIR"].(string)
|
||||
// if !ok || websiteDir == "" {
|
||||
// return path.Join(i.GetAppPath(), i.Name, "www")
|
||||
// }
|
||||
// return websiteDir
|
||||
//}
|
||||
|
||||
func (i *AppInstall) GetComposePath() string {
|
||||
return path.Join(i.GetAppPath(), i.Name, "docker-compose.yml")
|
||||
}
|
||||
|
@ -359,7 +359,11 @@ func (a AppService) Install(req request.AppInstallCreate) (appInstall *model.App
|
||||
siteDir = path.Join(constant.DataDir, dir.(string))
|
||||
}
|
||||
req.Params["WEBSITE_DIR"] = siteDir
|
||||
_ = settingRepo.Create("WEBSITE_DIR", siteDir)
|
||||
oldWebStePath, _ := settingRepo.GetValueByKey("WEBSITE_DIR")
|
||||
if oldWebStePath != "" && oldWebStePath != siteDir {
|
||||
_ = files.NewFileOp().Rename(oldWebStePath, siteDir)
|
||||
}
|
||||
_ = settingRepo.UpdateOrCreate("WEBSITE_DIR", siteDir)
|
||||
}
|
||||
}
|
||||
for key := range req.Params {
|
||||
|
@ -384,7 +384,8 @@ func deleteAppInstall(deleteReq request.AppInstallDelete) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if deleteReq.DeleteDB {
|
||||
resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithAppInstallId(install.ID))
|
||||
if deleteReq.DeleteDB && len(resources) > 0 {
|
||||
del := dto.DelAppLink{
|
||||
Ctx: ctx,
|
||||
Install: &install,
|
||||
@ -1062,8 +1063,9 @@ func upApp(task *task.Task, appInstall *model.AppInstall, pullImages bool) error
|
||||
}
|
||||
}
|
||||
appInstall.Message = errMsg + out
|
||||
task.LogFailedWithErr(i18n.GetMsgByKey("PullImage"), err)
|
||||
return err
|
||||
installErr := errors.New(appInstall.Message)
|
||||
task.LogFailedWithErr(i18n.GetMsgByKey("PullImage"), installErr)
|
||||
return installErr
|
||||
} else {
|
||||
task.Log(i18n.GetMsgByKey("PullImageSuccess"))
|
||||
}
|
||||
@ -1316,7 +1318,7 @@ func handleErr(install model.AppInstall, err error, out string) error {
|
||||
|
||||
func doNotNeedSync(installed model.AppInstall) bool {
|
||||
return installed.Status == constant.Installing || installed.Status == constant.Rebuilding || installed.Status == constant.Upgrading ||
|
||||
installed.Status == constant.Syncing || installed.Status == constant.Uninstalling
|
||||
installed.Status == constant.Syncing || installed.Status == constant.Uninstalling || installed.Status == constant.InstallErr
|
||||
}
|
||||
|
||||
func synAppInstall(containers map[string]types.Container, appInstall *model.AppInstall, force bool) {
|
||||
|
@ -51,6 +51,8 @@ type IFileService interface {
|
||||
ChangeMode(op request.FileCreate) error
|
||||
BatchChangeModeAndOwner(op request.FileRoleReq) error
|
||||
ReadLogByLine(req request.FileReadByLineReq) (*response.FileLineContent, error)
|
||||
|
||||
GetPathByType(pathType string) string
|
||||
}
|
||||
|
||||
var filteredPaths = []string{
|
||||
@ -483,3 +485,14 @@ func (f *FileService) ReadLogByLine(req request.FileReadByLineReq) (*response.Fi
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (f *FileService) GetPathByType(pathType string) string {
|
||||
if pathType == "websiteDir" {
|
||||
value, _ := settingRepo.GetValueByKey("WEBSITE_DIR")
|
||||
if value == "" {
|
||||
return path.Join(global.CONF.System.BaseDir, "www")
|
||||
}
|
||||
return value
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
@ -91,12 +91,6 @@ func createIndexFile(website *model.Website, runtime *model.Runtime) error {
|
||||
}
|
||||
|
||||
func createProxyFile(website *model.Website) error {
|
||||
//nginxInstall, err := getAppInstallByKey(constant.AppOpenresty)
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
//
|
||||
//proxyFolder := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "www", "sites", website.Alias, "proxy")
|
||||
proxyFolder := GetSitePath(*website, SiteProxyDir)
|
||||
filePath := path.Join(proxyFolder, "root.conf")
|
||||
fileOp := files.NewFileOp()
|
||||
@ -282,10 +276,6 @@ func createWafConfig(website *model.Website, domains []model.WebsiteDomain) erro
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !common.CompareVersion(nginxInstall.Version, "1.21.4.3-2-0") {
|
||||
return nil
|
||||
}
|
||||
wafDataPath := path.Join(nginxInstall.GetPath(), "1pwaf", "data")
|
||||
fileOp := files.NewFileOp()
|
||||
if !fileOp.Stat(wafDataPath) {
|
||||
|
@ -30,7 +30,7 @@ ErrDockerComposeNotValid: "docker-compose file format error!"
|
||||
ErrUpdateBuWebsite: "The application was updated successfully, but the modification of the website configuration file failed, please check the configuration!"
|
||||
Err1PanelNetworkFailed: "Default container network creation failed! {{ .detail }}"
|
||||
ErrFileParse: "Application docker-compose file parsing failed!"
|
||||
ErrInstallDirNotFound: "installation directory does not exist"
|
||||
ErrInstallDirNotFound: "The installation directory does not exist. To uninstall it, please choose to force uninstall."
|
||||
AppStoreIsUpToDate: "The app store is already up to date!"
|
||||
LocalAppVersionNull: "The {{.name}} app is not synced to version! Could not add to application list"
|
||||
LocalAppVersionErr: "{{.name}} failed to sync version {{.version}}! {{.err}}"
|
||||
|
@ -31,7 +31,7 @@ ErrDockerComposeNotValid: "docker-compose 文件格式錯誤"
|
||||
ErrUpdateBuWebsite: "應用更新成功,但是網站配置文件修改失敗,請檢查配置!"
|
||||
Err1PanelNetworkFailed: "默認容器網絡創建失敗!{{ .detail }}"
|
||||
ErrFileParse: "應用 docker-compose 文件解析失敗!"
|
||||
ErrInstallDirNotFound: "安裝目錄不存在"
|
||||
ErrInstallDirNotFound: "安裝目錄不存在,如需卸載,請選擇強制卸載"
|
||||
AppStoreIsUpToDate: "應用商店已經是最新版本"
|
||||
LocalAppVersionNull: "{{.name}} 應用未同步到版本!無法添加到應用列表"
|
||||
LocalAppVersionErr: "{{.name}} 同步版本 {{.version}} 失敗!{{.err}}"
|
||||
|
@ -30,7 +30,7 @@ ErrDockerComposeNotValid: "docker-compose 文件格式错误"
|
||||
ErrUpdateBuWebsite: "应用更新成功,但是网站配置文件修改失败,请检查配置!"
|
||||
Err1PanelNetworkFailed: "默认容器网络创建失败!{{ .detail }}"
|
||||
ErrFileParse: "应用 docker-compose 文件解析失败!"
|
||||
ErrInstallDirNotFound: "安装目录不存在"
|
||||
ErrInstallDirNotFound: "安装目录不存在,如需卸载,请选择强制卸载"
|
||||
AppStoreIsUpToDate: "应用商店已经是最新版本"
|
||||
LocalAppVersionNull: "{{.name}} 应用未同步到版本!无法添加到应用列表"
|
||||
LocalAppVersionErr: "{{.name}} 同步版本 {{.version}} 失败!{{.err}}"
|
||||
|
@ -47,5 +47,6 @@ func (f *FileRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
fileRouter.POST("/favorite", baseApi.CreateFavorite)
|
||||
fileRouter.POST("/favorite/del", baseApi.DeleteFavorite)
|
||||
|
||||
fileRouter.GET("/path/:type", baseApi.GetPathByType)
|
||||
}
|
||||
}
|
||||
|
@ -124,3 +124,7 @@ export const BatchChangeRole = (params: File.FileRole) => {
|
||||
export const GetRecycleStatus = () => {
|
||||
return http.get<string>('files/recycle/status');
|
||||
};
|
||||
|
||||
export const GetPathByType = (pathType: string) => {
|
||||
return http.get<string>(`files/path/${pathType}`);
|
||||
};
|
||||
|
@ -87,7 +87,7 @@ const search = async () => {
|
||||
};
|
||||
|
||||
const openTaskLog = (row: Log.Task) => {
|
||||
taskLogRef.value.openWithTaskID(row.id, !(row.status == 'Executing'));
|
||||
taskLogRef.value.openWithTaskID(row.id, row.status == 'Executing');
|
||||
};
|
||||
|
||||
const acceptParams = () => {
|
||||
|
@ -43,7 +43,6 @@ const open = ref(false);
|
||||
const showTail = ref(true);
|
||||
|
||||
const openWithTaskID = (id: string, tail: boolean) => {
|
||||
console.log('openWithTaskID', id, tail);
|
||||
config.taskID = id;
|
||||
if (tail === undefined) {
|
||||
config.tail = true;
|
||||
|
@ -302,6 +302,7 @@ const message = {
|
||||
sending: 'Sending',
|
||||
healthy: 'Normal',
|
||||
executing: 'Executing',
|
||||
installerr: 'Install Error',
|
||||
},
|
||||
units: {
|
||||
second: 'Second',
|
||||
@ -2007,6 +2008,9 @@ const message = {
|
||||
'The default access is used for application port forwarding. For example, if the application port is 8080, the forwarding address would be http(s)://default-access-address:8080',
|
||||
webUIConfig: 'Please add the access address in the application parameters or the app store settings',
|
||||
toLink: 'Open',
|
||||
customAppHelper:
|
||||
'The current package is from the main node app store, please modify the configuration on the main node',
|
||||
forceUninstall: 'Force Uninstall',
|
||||
},
|
||||
website: {
|
||||
website: 'Website',
|
||||
|
@ -297,6 +297,7 @@ const message = {
|
||||
sending: '下發中',
|
||||
healthy: '正常',
|
||||
executing: '執行中',
|
||||
installerr: '安裝失敗',
|
||||
},
|
||||
units: {
|
||||
second: '秒',
|
||||
@ -1863,6 +1864,8 @@ const message = {
|
||||
'默認訪問用於應用端口跳轉,例如應用端口為 8080 則跳轉地址為 http(s)://默認訪問地址:8080',
|
||||
webUIConfig: '請在應用參數或者應用商店設置處添加訪問地址',
|
||||
toLink: '連結',
|
||||
customAppHelper: '當前使用的是主節點應用商店包,修改配置請在主節點操作',
|
||||
forceUninstall: '強制卸載',
|
||||
},
|
||||
website: {
|
||||
website: '網站',
|
||||
|
@ -297,6 +297,7 @@ const message = {
|
||||
sending: '下发中',
|
||||
healthy: '正常',
|
||||
executing: '执行中',
|
||||
installerr: '安装失败',
|
||||
},
|
||||
units: {
|
||||
second: '秒',
|
||||
@ -1862,6 +1863,7 @@ const message = {
|
||||
webUIConfig: '请在应用参数或者应用商店设置处添加访问地址',
|
||||
toLink: '跳转',
|
||||
customAppHelper: '当前使用的是主节点应用商店包,修改配置请在主节点操作',
|
||||
forceUninstall: '强制卸载',
|
||||
},
|
||||
website: {
|
||||
website: '网站',
|
||||
|
@ -114,6 +114,7 @@ import { GetAppService } from '@/api/modules/app';
|
||||
import { Rules } from '@/global/form-rules';
|
||||
import { App } from '@/api/interface/app';
|
||||
import { getDBName } from '@/utils/util';
|
||||
import { GetPathByType } from '@/api/modules/files';
|
||||
|
||||
interface ParamObj extends App.FromField {
|
||||
services: App.AppService[];
|
||||
@ -186,6 +187,11 @@ const handleParams = () => {
|
||||
} else {
|
||||
form[p.envKey] = p.default;
|
||||
}
|
||||
if (p.type == 'text' && p.envKey == 'WEBSITE_DIR') {
|
||||
GetPathByType('websiteDir').then((res) => {
|
||||
form[p.envKey] = res.data;
|
||||
});
|
||||
}
|
||||
if (p.required) {
|
||||
if (p.type === 'service' || p.type === 'apps') {
|
||||
rules[p.envKey] = [Rules.requiredSelect];
|
||||
|
@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<DialogPro v-model="open" :title="$t('commons.button.delete') + ' - ' + appInstallName" @close="handleClose">
|
||||
<DialogPro v-model="open" :title="$t('commons.button.uninstall') + ' - ' + appInstallName" @close="handleClose">
|
||||
<el-form ref="deleteForm" label-position="left" v-loading="loading">
|
||||
<el-form-item>
|
||||
<el-checkbox v-model="deleteReq.forceDelete" :label="$t('app.forceDelete')" />
|
||||
<el-checkbox v-model="deleteReq.forceDelete" :label="$t('app.forceUninstall')" />
|
||||
<span class="input-help">
|
||||
{{ $t('app.forceDeleteHelper') }}
|
||||
</span>
|
||||
|
Loading…
x
Reference in New Issue
Block a user