mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-24 06:27:37 +08:00
fix:Fix issue with error during OpenResty reinstallation (#8117)
This commit is contained in:
parent
6c251e1a49
commit
c56456203f
2 changed files with 31 additions and 0 deletions
|
|
@ -537,6 +537,11 @@ func (a AppService) Install(req request.AppInstallCreate) (appInstall *model.App
|
|||
if err = runScript(t, appInstall, "init"); err != nil {
|
||||
return err
|
||||
}
|
||||
if app.Key == "openresty" {
|
||||
if err = handleOpenrestyFile(appInstall); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err = upApp(t, appInstall, req.PullImage); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1821,3 +1821,29 @@ func getAppTags(appID uint, lang string) ([]response.TagDTO, error) {
|
|||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func handleOpenrestyFile(appInstall *model.AppInstall) error {
|
||||
websites, _ := websiteRepo.List()
|
||||
if len(websites) == 0 {
|
||||
return nil
|
||||
}
|
||||
hasDefaultWebsite := false
|
||||
for _, website := range websites {
|
||||
if website.DefaultServer {
|
||||
hasDefaultWebsite = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !hasDefaultWebsite {
|
||||
return nil
|
||||
}
|
||||
installDir := appInstall.GetPath()
|
||||
defaultConfigPath := path.Join(installDir, "conf", "default", "00.default.conf")
|
||||
fileOp := files.NewFileOp()
|
||||
content, err := fileOp.GetContent(defaultConfigPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
newContent := strings.ReplaceAll(string(content), "default_server", "")
|
||||
return fileOp.WriteFile(defaultConfigPath, strings.NewReader(newContent), constant.FilePerm)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue