2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-12 22:02:23 +00:00

Respect GOMAXPROCS variable

Closes #535
This commit is contained in:
damekr 2016-08-03 20:29:08 +02:00 committed by Damian Rajca
parent c9ab75a44c
commit be00d91967

View File

@ -2,17 +2,23 @@ package main
import ( import (
"fmt" "fmt"
"os"
"runtime"
"github.com/jessevdk/go-flags" "github.com/jessevdk/go-flags"
"os"
"restic" "restic"
"restic/debug" "restic/debug"
"runtime"
) )
func init() { func init() {
// set GOMAXPROCS to number of CPUs // 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() { func main() {