diff --git a/agent/app/service/app.go b/agent/app/service/app.go index a7111585f..4f6ccd84e 100644 --- a/agent/app/service/app.go +++ b/agent/app/service/app.go @@ -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 { diff --git a/agent/app/service/runtime_utils.go b/agent/app/service/runtime_utils.go index 7f486b72c..0c283938f 100644 --- a/agent/app/service/runtime_utils.go +++ b/agent/app/service/runtime_utils.go @@ -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) + }() + } +}