fix: fix issue with install runtime (#8630)

This commit is contained in:
CityFun 2025-05-14 14:06:25 +08:00 committed by GitHub
parent 7fc829d3a6
commit 0941b0aad3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 0 deletions

View file

@ -375,6 +375,7 @@ func (a AppService) Install(req request.AppInstallCreate) (appInstall *model.App
if err != nil {
return
}
go RestartPHPRuntime()
}
}
for key := range req.Params {

View file

@ -422,6 +422,9 @@ func handleParams(create request.RuntimeCreate, projectDir string) (composeConte
}
create.Params["CONTAINER_PACKAGE_URL"] = create.Source
siteDir, _ := settingRepo.Get(settingRepo.WithByKey("WEBSITE_DIR"))
if siteDir.Value == "" {
siteDir.Value = path.Join(global.Dir.BaseDir, "1panel", "www")
}
create.Params["PANEL_WEBSITE_DIR"] = siteDir.Value
composeContent, err = handleEnvironments(composeContent, create, projectDir)
if err != nil {
@ -841,3 +844,26 @@ func getExtensionDir(version string) string {
}
return ""
}
func RestartPHPRuntime() {
runtimes, err := runtimeRepo.List(repo.WithByType(constant.RuntimePHP))
if err != nil {
return
}
websiteDir, _ := settingRepo.GetValueByKey("WEBSITE_DIR")
for _, runtime := range runtimes {
envs, err := gotenv.Unmarshal(runtime.Env)
if err != nil {
global.LOG.Warningf("restart php runtime failed %v", err)
continue
}
envs["PANEL_WEBSITE_DIR"] = websiteDir
if err = gotenv.Write(envs, runtime.GetEnvPath()); err != nil {
global.LOG.Warningf("restart php runtime failed %v", err)
continue
}
go func() {
_ = restartRuntime(&runtime)
}()
}
}