fix: 解决 Node.js 运行环境网站停止失败的问题 (#3734)

This commit is contained in:
zhengkunwang 2024-01-29 16:34:32 +08:00 committed by GitHub
parent 0ee942cbef
commit 7a45db71d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -556,7 +556,15 @@ func opWebsite(website *model.Website, operate string) error {
case constant.Deployment:
server.RemoveDirective("location", []string{"/"})
case constant.Runtime:
server.RemoveDirective("location", []string{"~", "[^/]\\.php(/|$)"})
runtime, err := runtimeRepo.GetFirst(commonRepo.WithByID(website.RuntimeID))
if err != nil {
return err
}
if runtime.Type == constant.RuntimePHP {
server.RemoveDirective("location", []string{"~", "[^/]\\.php(/|$)"})
} else {
server.RemoveDirective("location", []string{"/"})
}
}
server.UpdateRoot("/usr/share/nginx/html/stop")
website.Status = constant.WebStopped
@ -594,10 +602,19 @@ func opWebsite(website *model.Website, operate string) error {
case constant.Runtime:
server.UpdateRoot(rootIndex)
localPath := ""
if website.ProxyType == constant.RuntimeProxyUnix {
localPath = path.Join(nginxInstall.Install.GetPath(), rootIndex, "index.php")
runtime, err := runtimeRepo.GetFirst(commonRepo.WithByID(website.RuntimeID))
if err != nil {
return err
}
if runtime.Type == constant.RuntimePHP {
if website.ProxyType == constant.RuntimeProxyUnix {
localPath = path.Join(nginxInstall.Install.GetPath(), rootIndex, "index.php")
}
server.UpdatePHPProxy([]string{website.Proxy}, localPath)
} else {
proxy := fmt.Sprintf("http://127.0.0.1:%d", runtime.Port)
server.UpdateRootProxy([]string{proxy})
}
server.UpdatePHPProxy([]string{website.Proxy}, localPath)
}
website.Status = constant.WebRunning
now := time.Now()