From 5e17fbdaca9fca5a058522a7e2060d48cd9724cc Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 8 May 2013 18:30:39 -0700 Subject: [PATCH] packer: Set GOMAXPROCS for number of CPU if n ot set --- packer.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packer.go b/packer.go index 9a5220321..0cd8c9d3a 100644 --- a/packer.go +++ b/packer.go @@ -8,6 +8,7 @@ import ( "io/ioutil" "log" "os" + "runtime" ) func main() { @@ -19,6 +20,11 @@ func main() { log.SetOutput(os.Stderr) } + // If there is no explicit number of Go threads to use, then set it + if os.Getenv("GOMAXPROCS") == "" { + runtime.GOMAXPROCS(runtime.NumCPU()) + } + defer plugin.CleanupClients() config, err := parseConfig(defaultConfig)