mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-24 11:09:16 +08:00
fix: 解决网站 PHP 版本切换报错的问题 (#3228)
This commit is contained in:
parent
fb709e7eaf
commit
d4def44545
@ -9,6 +9,7 @@ import (
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
||||
"os"
|
||||
"path"
|
||||
"reflect"
|
||||
@ -1247,6 +1248,7 @@ func (w WebsiteService) ChangePHPVersion(req request.WebsitePHPVersionReq) error
|
||||
phpDir = path.Join(constant.RuntimeDir, runtime.Type, runtime.Name, "php")
|
||||
oldFmContent, _ = fileOp.GetContent(fpmConfDir)
|
||||
newComposeByte []byte
|
||||
supervisorDir = path.Join(appInstall.GetPath(), "supervisor")
|
||||
)
|
||||
envParams := make(map[string]string, len(envs))
|
||||
handleMap(envs, envParams)
|
||||
@ -1267,7 +1269,7 @@ func (w WebsiteService) ChangePHPVersion(req request.WebsitePHPVersionReq) error
|
||||
return busErr
|
||||
}
|
||||
|
||||
newComposeByte, busErr = changeServiceName(composePath, appInstall.ServiceName)
|
||||
newComposeByte, busErr = changeServiceName(appDetail.DockerCompose, appInstall.ServiceName)
|
||||
if busErr != nil {
|
||||
return err
|
||||
}
|
||||
@ -1288,6 +1290,22 @@ func (w WebsiteService) ChangePHPVersion(req request.WebsitePHPVersionReq) error
|
||||
return busErr
|
||||
}
|
||||
}
|
||||
if common.CompareVersion(appDetail.Version, "7.0") && !fileOp.Stat(supervisorDir) {
|
||||
if appDetail.Update {
|
||||
app, err := appRepo.GetFirst(commonRepo.WithByID(appDetail.AppId))
|
||||
if err != nil {
|
||||
busErr = err
|
||||
return busErr
|
||||
}
|
||||
if busErr = downloadApp(app, appDetail, nil); err != nil {
|
||||
return busErr
|
||||
}
|
||||
}
|
||||
if busErr = fileOp.CopyDir(path.Join(phpDir, "supervisor"), appInstall.GetPath()); err != nil {
|
||||
return busErr
|
||||
}
|
||||
}
|
||||
|
||||
if out, err := compose.Up(appInstall.GetComposePath()); err != nil {
|
||||
if out != "" {
|
||||
busErr = errors.New(out)
|
||||
|
@ -651,11 +651,9 @@ func chownRootDir(path string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func changeServiceName(composePath, newServiceName string) (composeByte []byte, err error) {
|
||||
func changeServiceName(newComposeContent, newServiceName string) (composeByte []byte, err error) {
|
||||
composeMap := make(map[string]interface{})
|
||||
fileOp := files.NewFileOp()
|
||||
composeContent, _ := fileOp.GetContent(composePath)
|
||||
if err = yaml.Unmarshal(composeContent, &composeMap); err != nil {
|
||||
if err = yaml.Unmarshal([]byte(newComposeContent), &composeMap); err != nil {
|
||||
return
|
||||
}
|
||||
value, ok := composeMap["services"]
|
||||
|
Loading…
Reference in New Issue
Block a user