mirror of
https://github.com/octoleo/restic.git
synced 2024-11-30 08:44:02 +00:00
Merge pull request #562 from damekr/implement-gomaxprocs-env
Issue-535: restic respect GOMAXPROCS env variable depending on go version
This commit is contained in:
commit
4b8b625b90
@ -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() {
|
||||||
|
Loading…
Reference in New Issue
Block a user