Merge pull request #516 from aledbf/workers-auto

Convert WorkerProcesses setting to string to allow the value auto
This commit is contained in:
Manuel Alejandro de Brito Fontes 2017-03-28 19:59:22 -03:00 committed by GitHub
commit 39feaf10df
2 changed files with 9 additions and 3 deletions

View file

@ -25,6 +25,7 @@ import (
"net/http" "net/http"
"os" "os"
"os/exec" "os/exec"
"strconv"
"syscall" "syscall"
"time" "time"
@ -364,7 +365,11 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) ([]byte, er
// the limit of open files is per worker process // the limit of open files is per worker process
// and we leave some room to avoid consuming all the FDs available // and we leave some room to avoid consuming all the FDs available
maxOpenFiles := (sysctlFSFileMax() / cfg.WorkerProcesses) - 1024 wp, err := strconv.Atoi(cfg.WorkerProcesses)
if err != nil {
wp = 1
}
maxOpenFiles := (sysctlFSFileMax() / wp) - 1024
setHeaders := map[string]string{} setHeaders := map[string]string{}
if cfg.ProxySetHeaders != "" { if cfg.ProxySetHeaders != "" {

View file

@ -19,6 +19,7 @@ package config
import ( import (
"fmt" "fmt"
"runtime" "runtime"
"strconv"
"github.com/golang/glog" "github.com/golang/glog"
@ -252,7 +253,7 @@ type Configuration struct {
// Defines the number of worker processes. By default auto means number of available CPU cores // Defines the number of worker processes. By default auto means number of available CPU cores
// http://nginx.org/en/docs/ngx_core_module.html#worker_processes // http://nginx.org/en/docs/ngx_core_module.html#worker_processes
WorkerProcesses int `json:"worker-processes,omitempty"` WorkerProcesses string `json:"worker-processes,omitempty"`
} }
// NewDefault returns the default nginx configuration // NewDefault returns the default nginx configuration
@ -285,7 +286,7 @@ func NewDefault() Configuration {
SSLSessionTickets: true, SSLSessionTickets: true,
SSLSessionTimeout: sslSessionTimeout, SSLSessionTimeout: sslSessionTimeout,
UseGzip: true, UseGzip: true,
WorkerProcesses: runtime.NumCPU(), WorkerProcesses: strconv.Itoa(runtime.NumCPU()),
VtsStatusZoneSize: "10m", VtsStatusZoneSize: "10m",
UseHTTP2: true, UseHTTP2: true,
Backend: defaults.Backend{ Backend: defaults.Backend{