From dd4fb1d62a40251d2e5d3592ab24e12e6b47c219 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 5 Jun 2013 17:39:27 -0700 Subject: [PATCH] packer/plugin: Explicitly set GOMAXPROCS to # of cpus --- packer/plugin/plugin.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packer/plugin/plugin.go b/packer/plugin/plugin.go index faec6238a..c6fd07163 100644 --- a/packer/plugin/plugin.go +++ b/packer/plugin/plugin.go @@ -16,6 +16,7 @@ import ( "net/rpc" "os" "os/signal" + "runtime" "strconv" "strings" ) @@ -23,6 +24,11 @@ import ( // This serves a single RPC connection on the given RPC server on // a random port. func serve(server *rpc.Server) (err error) { + // If there is no explicit number of Go threads to use, then set it + if os.Getenv("GOMAXPROCS") == "" { + runtime.GOMAXPROCS(runtime.NumCPU()) + } + minPort, err := strconv.ParseInt(os.Getenv("PACKER_PLUGIN_MIN_PORT"), 10, 32) if err != nil { return