Browse Source

Merge pull request #3374 from yichengq/gomaxprocs

etcdmain: change default GOMAXPROCS when compiling in go1.5
Yicheng Qin 10 years ago
parent
commit
2b58da1699
1 changed files with 1 additions and 6 deletions
  1. 1 6
      etcdmain/etcd.go

+ 1 - 6
etcdmain/etcd.go

@@ -24,7 +24,6 @@ import (
 	"path"
 	"path"
 	"reflect"
 	"reflect"
 	"runtime"
 	"runtime"
-	"strconv"
 	"time"
 	"time"
 
 
 	"github.com/coreos/etcd/Godeps/_workspace/src/github.com/coreos/go-systemd/daemon"
 	"github.com/coreos/etcd/Godeps/_workspace/src/github.com/coreos/go-systemd/daemon"
@@ -96,12 +95,8 @@ func Main() {
 	plog.Infof("Go Version: %s\n", runtime.Version())
 	plog.Infof("Go Version: %s\n", runtime.Version())
 	plog.Infof("Go OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH)
 	plog.Infof("Go OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH)
 
 
-	GoMaxProcs := 1
-	if envMaxProcs, err := strconv.Atoi(os.Getenv("GOMAXPROCS")); err == nil {
-		GoMaxProcs = envMaxProcs
-	}
+	GoMaxProcs := runtime.GOMAXPROCS(0)
 	plog.Infof("setting maximum number of CPUs to %d, total number of available CPUs is %d", GoMaxProcs, runtime.NumCPU())
 	plog.Infof("setting maximum number of CPUs to %d, total number of available CPUs is %d", GoMaxProcs, runtime.NumCPU())
-	runtime.GOMAXPROCS(GoMaxProcs)
 
 
 	// TODO: check whether fields are set instead of whether fields have default value
 	// TODO: check whether fields are set instead of whether fields have default value
 	if cfg.name != defaultName && cfg.initialCluster == initialClusterFromName(defaultName) {
 	if cfg.name != defaultName && cfg.initialCluster == initialClusterFromName(defaultName) {