From be00d91967e89e36453193b5dfe55140b9f113af Mon Sep 17 00:00:00 2001 From: damekr Date: Wed, 3 Aug 2016 20:29:08 +0200 Subject: [PATCH] Respect GOMAXPROCS variable Closes #535 --- src/cmds/restic/main.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cmds/restic/main.go b/src/cmds/restic/main.go index 3fcce230f..19d81e774 100644 --- a/src/cmds/restic/main.go +++ b/src/cmds/restic/main.go @@ -2,17 +2,23 @@ package main import ( "fmt" - "os" - "runtime" - "github.com/jessevdk/go-flags" + "os" "restic" "restic/debug" + "runtime" ) func init() { // set GOMAXPROCS to number of CPUs - runtime.GOMAXPROCS(runtime.NumCPU()) + if runtime.Version() < "go1.5" { + gomaxprocs := os.Getenv("GOMAXPROCS") + debug.Log("restic", "read GOMAXPROCS from env variable, value: %s", gomaxprocs) + if gomaxprocs == "" { + runtime.GOMAXPROCS(runtime.NumCPU()) + } + } + } func main() {