diff options
Diffstat (limited to 'coremain/run.go')
-rw-r--r-- | coremain/run.go | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/coremain/run.go b/coremain/run.go index e6f51295f..5f3b610bd 100644 --- a/coremain/run.go +++ b/coremain/run.go @@ -2,14 +2,12 @@ package coremain import ( - "errors" "flag" "fmt" "io/ioutil" "log" "os" "runtime" - "strconv" "strings" "github.com/coredns/coredns/core/dnsserver" @@ -24,7 +22,6 @@ func init() { setVersion() flag.StringVar(&conf, "conf", "", "Corefile to load (default \""+caddy.DefaultConfigFile+"\")") - flag.StringVar(&cpu, "cpu", "100%", "CPU cap") flag.BoolVar(&plugins, "plugins", false, "List installed plugins") flag.StringVar(&caddy.PidFile, "pidfile", "", "Path to write pid file") flag.BoolVar(&version, "version", false, "Show version") @@ -73,11 +70,6 @@ func Run() { os.Exit(0) } - // Set CPU cap - if err := setCPU(cpu); err != nil { - mustLogFatal(err) - } - // Get Corefile input corefile, err := caddy.LoadCaddyfile(serverType) if err != nil { @@ -194,45 +186,9 @@ func setVersion() { } } -// setCPU parses string cpu and sets GOMAXPROCS -// according to its value. It accepts either -// a number (e.g. 3) or a percent (e.g. 50%). -func setCPU(cpu string) error { - var numCPU int - - availCPU := runtime.NumCPU() - - if strings.HasSuffix(cpu, "%") { - // Percent - var percent float32 - pctStr := cpu[:len(cpu)-1] - pctInt, err := strconv.Atoi(pctStr) - if err != nil || pctInt < 1 || pctInt > 100 { - return errors.New("invalid CPU value: percentage must be between 1-100") - } - percent = float32(pctInt) / 100 - numCPU = int(float32(availCPU) * percent) - } else { - // Number - num, err := strconv.Atoi(cpu) - if err != nil || num < 1 { - return errors.New("invalid CPU value: provide a number or percent greater than 0") - } - numCPU = num - } - - if numCPU > availCPU { - numCPU = availCPU - } - - runtime.GOMAXPROCS(numCPU) - return nil -} - // Flags that control program flow or startup var ( conf string - cpu string logfile bool version bool plugins bool |