packer/plugin: Explicitly set GOMAXPROCS to # of cpus

This commit is contained in:
Mitchell Hashimoto 2013-06-05 17:39:27 -07:00
parent aefb947fa9
commit dd4fb1d62a
1 changed files with 6 additions and 0 deletions

View File

@ -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