feat: add field of nginx worker processes mode

This commit is contained in:
Akino 2025-04-10 13:53:39 +00:00
parent d487af0567
commit bdb347cb24
No known key found for this signature in database
GPG key ID: FB2F74D193A40907
8 changed files with 36 additions and 20 deletions

View file

@ -10,8 +10,9 @@ import (
)
type NginxConfigInfo struct {
WorkerProcesses int `json:"worker_processes"`
WorkerConnections int `json:"worker_connections"`
WorkerProcesses int `json:"worker_processes"`
WorkerConnections int `json:"worker_connections"`
ProcessMode string `json:"process_mode"`
}
// GetNginxWorkerConfigInfo Get Nginx config info of worker_processes and worker_connections
@ -19,6 +20,7 @@ func GetNginxWorkerConfigInfo() (*NginxConfigInfo, error) {
result := &NginxConfigInfo{
WorkerProcesses: 1,
WorkerConnections: 1024,
ProcessMode: "manual",
}
// Get worker_processes config
@ -33,8 +35,10 @@ func GetNginxWorkerConfigInfo() (*NginxConfigInfo, error) {
if matches := wpRe.FindStringSubmatch(string(output)); len(matches) > 1 {
if matches[1] == "auto" {
result.WorkerProcesses = runtime.NumCPU()
result.ProcessMode = "auto"
} else {
result.WorkerProcesses, _ = strconv.Atoi(matches[1])
result.ProcessMode = "manual"
}
}