maxprocs exposed by flag
This commit is contained in:
parent
6623098853
commit
bc9d3d209d
1 changed files with 5 additions and 3 deletions
8
main.go
8
main.go
|
@ -21,13 +21,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
maxprocs int
|
||||||
profile bool
|
profile bool
|
||||||
configPath string
|
configPath string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
flag.IntVar(&maxprocs, "maxprocs", runtime.NumCPU(), "Specify the amount of OS threads used by the runtime")
|
||||||
flag.BoolVar(&profile, "profile", false, "Generate profiling data for pprof into ./chihaya.cpu")
|
flag.BoolVar(&profile, "profile", false, "Generate profiling data for pprof into ./chihaya.cpu")
|
||||||
flag.StringVar(&configPath, "config", "", "Provide the filesystem path of a valid configuration file.")
|
flag.StringVar(&configPath, "config", "", "Provide the filesystem path of a valid configuration file")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Boot() {
|
func Boot() {
|
||||||
|
@ -35,8 +37,8 @@ func Boot() {
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(maxprocs)
|
||||||
glog.Info("set gomaxprocs to ", runtime.NumCPU())
|
glog.Info("set gomaxprocs to ", maxprocs)
|
||||||
|
|
||||||
if profile {
|
if profile {
|
||||||
f, err := os.Create("chihaya.cpu")
|
f, err := os.Create("chihaya.cpu")
|
||||||
|
|
Loading…
Reference in a new issue