aboutsummaryrefslogtreecommitdiff
path: root/coremain/run.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2019-07-03 20:12:51 +0100
committerGravatar GitHub <noreply@github.com> 2019-07-03 20:12:51 +0100
commitf5fe98395e2777907cdbfee08d37f12b4c1931c7 (patch)
tree31fcf4ac6eea214db71a3f44193226a338db01e0 /coremain/run.go
parente0c373ec12c7c043022fb9779da97f095b7f5bf8 (diff)
downloadcoredns-f5fe98395e2777907cdbfee08d37f12b4c1931c7.tar.gz
coredns-f5fe98395e2777907cdbfee08d37f12b4c1931c7.tar.zst
coredns-f5fe98395e2777907cdbfee08d37f12b4c1931c7.zip
Remove -cpu flag (#2793)
The -cpu flag is a weird one (and copied originally from Caddy), it basically sets GOMAXPROCS which can be *easily* done by just setting that environment variable. Also with systemd and containerized env you set this externally *anyway*, so there is little use to do this again in the binary. Also the option's help was confusing (i.e. percentage of what?). Remove the option and supporting files. Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'coremain/run.go')
-rw-r--r--coremain/run.go44
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