mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat: add field of nginx worker processes mode
This commit is contained in:
parent
d487af0567
commit
bdb347cb24
8 changed files with 36 additions and 20 deletions
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue