From 88e3ac88e5919e7ec46edfe90266c26640157808 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 <1paneldev@sina.com> Date: Mon, 22 Sep 2025 11:16:40 +0800 Subject: [PATCH] feat: add timeout limit function Config for PHP --- agent/app/dto/request/runtime.go | 1 + agent/app/dto/response/website.go | 21 +++-- agent/app/service/runtime.go | 13 +++ frontend/src/api/interface/runtime.ts | 2 + frontend/src/api/modules/runtime.ts | 2 +- .../website/runtime/php/config/index.vue | 4 + .../runtime/php/config/timeout/index.vue | 92 +++++++++++++++++++ 7 files changed, 124 insertions(+), 11 deletions(-) create mode 100644 frontend/src/views/website/runtime/php/config/timeout/index.vue diff --git a/agent/app/dto/request/runtime.go b/agent/app/dto/request/runtime.go index e61bb934f32e..0ef656833a32 100644 --- a/agent/app/dto/request/runtime.go +++ b/agent/app/dto/request/runtime.go @@ -100,6 +100,7 @@ type PHPConfigUpdate struct { Scope string `json:"scope" validate:"required"` DisableFunctions []string `json:"disableFunctions"` UploadMaxSize string `json:"uploadMaxSize"` + MaxExecutionTime string `json:"maxExecutionTime"` } type PHPFileUpdate struct { diff --git a/agent/app/dto/response/website.go b/agent/app/dto/response/website.go index 3f4570e1a82d..0f6dcb6bacb8 100644 --- a/agent/app/dto/response/website.go +++ b/agent/app/dto/response/website.go @@ -59,16 +59,16 @@ type WebsiteNginxConfig struct { } type WebsiteHTTPS struct { - Enable bool `json:"enable"` - HttpConfig string `json:"httpConfig"` - SSL model.WebsiteSSL `json:"SSL"` - SSLProtocol []string `json:"SSLProtocol"` - Algorithm string `json:"algorithm"` - Hsts bool `json:"hsts"` - HstsIncludeSubDomains bool `json:"hstsIncludeSubDomains"` - HttpsPorts []int `json:"httpsPorts"` - HttpsPort string `json:"httpsPort"` - Http3 bool `json:"http3"` + Enable bool `json:"enable"` + HttpConfig string `json:"httpConfig"` + SSL model.WebsiteSSL `json:"SSL"` + SSLProtocol []string `json:"SSLProtocol"` + Algorithm string `json:"algorithm"` + Hsts bool `json:"hsts"` + HstsIncludeSubDomains bool `json:"hstsIncludeSubDomains"` + HttpsPorts []int `json:"httpsPorts"` + HttpsPort string `json:"httpsPort"` + Http3 bool `json:"http3"` } type WebsiteLog struct { @@ -82,6 +82,7 @@ type PHPConfig struct { Params map[string]string `json:"params"` DisableFunctions []string `json:"disableFunctions"` UploadMaxSize string `json:"uploadMaxSize"` + MaxExecutionTime string `json:"maxExecutionTime"` } type NginxRewriteRes struct { diff --git a/agent/app/service/runtime.go b/agent/app/service/runtime.go index 414cd2d6bbe7..4cf1decbdf85 100644 --- a/agent/app/service/runtime.go +++ b/agent/app/service/runtime.go @@ -860,6 +860,10 @@ func (r *RuntimeService) GetPHPConfig(id uint) (*response.PHPConfig, error) { if uploadMaxSize != "" { res.UploadMaxSize = uploadMaxSize } + timeout := phpConfig.Key("max_execution_time").Value() + if timeout != "" { + res.MaxExecutionTime = timeout + } return res, nil } @@ -912,6 +916,15 @@ func (r *RuntimeService) UpdatePHPConfig(req request.PHPConfigUpdate) (err error if matched, _ := regexp.MatchString(patternUpload, line); matched { lines[i] = "upload_max_filesize" + " = " + req.UploadMaxSize } + case "max_execution_time": + pattern := "^" + regexp.QuoteMeta("max_execution_time") + "\\s*=\\s*.*$" + if matched, _ := regexp.MatchString(pattern, line); matched { + lines[i] = "max_execution_time" + " = " + req.MaxExecutionTime + } + patternInput := "^" + regexp.QuoteMeta("max_input_time") + "\\s*=\\s*.*$" + if matched, _ := regexp.MatchString(patternInput, line); matched { + lines[i] = "max_input_time" + " = " + req.MaxExecutionTime + } } } updatedContent := strings.Join(lines, "\n") diff --git a/frontend/src/api/interface/runtime.ts b/frontend/src/api/interface/runtime.ts index c68cbcaf9bf8..bedd5d0a367f 100644 --- a/frontend/src/api/interface/runtime.ts +++ b/frontend/src/api/interface/runtime.ts @@ -163,6 +163,7 @@ export namespace Runtime { params: any; disableFunctions: string[]; uploadMaxSize: string; + maxExecutionTime: string; } export interface PHPConfigUpdate { @@ -171,6 +172,7 @@ export namespace Runtime { disableFunctions?: string[]; scope: string; uploadMaxSize?: string; + maxExecutionTime?: string; } export interface PHPUpdate { diff --git a/frontend/src/api/modules/runtime.ts b/frontend/src/api/modules/runtime.ts index 5ddb601b8eb4..8c706b7212d3 100644 --- a/frontend/src/api/modules/runtime.ts +++ b/frontend/src/api/modules/runtime.ts @@ -87,7 +87,7 @@ export const GetPHPConfig = (id: number) => { }; export const UpdatePHPConfig = (req: Runtime.PHPConfigUpdate) => { - return http.post(`/runtimes/php/config/`, req); + return http.post(`/runtimes/php/config`, req); }; export const UpdatePHPFile = (req: Runtime.PHPUpdate) => { diff --git a/frontend/src/views/website/runtime/php/config/index.vue b/frontend/src/views/website/runtime/php/config/index.vue index e38162086f35..64ecea5d8e3c 100644 --- a/frontend/src/views/website/runtime/php/config/index.vue +++ b/frontend/src/views/website/runtime/php/config/index.vue @@ -20,6 +20,9 @@ + + + @@ -47,6 +50,7 @@ import PHP from './php-fpm/index.vue'; import Performance from './performance/index.vue'; import Container from './container/index.vue'; import FpmStatus from './fpm-status/index.vue'; +import Timeout from './timeout/index.vue'; const index = ref('6'); const open = ref(false); diff --git a/frontend/src/views/website/runtime/php/config/timeout/index.vue b/frontend/src/views/website/runtime/php/config/timeout/index.vue new file mode 100644 index 000000000000..52774c1ebd95 --- /dev/null +++ b/frontend/src/views/website/runtime/php/config/timeout/index.vue @@ -0,0 +1,92 @@ + +