Skip to content

Commit

Permalink
Merge pull request #516 from aledbf/workers-auto
Browse files Browse the repository at this point in the history
Convert WorkerProcesses setting to string to allow the value auto
  • Loading branch information
aledbf authored Mar 28, 2017
2 parents 0aaffc9 + 1278a97 commit 39feaf1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion controllers/nginx/pkg/cmd/controller/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"net/http"
"os"
"os/exec"
"strconv"
"syscall"
"time"

Expand Down Expand Up @@ -364,7 +365,11 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) ([]byte, er

// the limit of open files is per worker process
// 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{}
if cfg.ProxySetHeaders != "" {
Expand Down
5 changes: 3 additions & 2 deletions controllers/nginx/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package config
import (
"fmt"
"runtime"
"strconv"

"github.com/golang/glog"

Expand Down Expand Up @@ -252,7 +253,7 @@ type Configuration struct {

// 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
WorkerProcesses int `json:"worker-processes,omitempty"`
WorkerProcesses string `json:"worker-processes,omitempty"`
}

// NewDefault returns the default nginx configuration
Expand Down Expand Up @@ -285,7 +286,7 @@ func NewDefault() Configuration {
SSLSessionTickets: true,
SSLSessionTimeout: sslSessionTimeout,
UseGzip: true,
WorkerProcesses: runtime.NumCPU(),
WorkerProcesses: strconv.Itoa(runtime.NumCPU()),
VtsStatusZoneSize: "10m",
UseHTTP2: true,
Backend: defaults.Backend{
Expand Down

0 comments on commit 39feaf1

Please sign in to comment.