adjust runtime.GOMAXPROCS to match the container CPU quota, if any

This commit is contained in:
Nicola Murino 2020-09-03 18:09:45 +02:00
parent a59163e56c
commit afc411c51b
3 changed files with 14 additions and 1 deletions

1
go.mod
View file

@ -40,6 +40,7 @@ require (
github.com/stretchr/testify v1.6.1
github.com/studio-b12/gowebdav v0.0.0-20200303150724-9380631c29a1
go.etcd.io/bbolt v1.3.5
go.uber.org/automaxprocs v1.3.0
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a
golang.org/x/net v0.0.0-20200822124328-c89045814202
golang.org/x/sys v0.0.0-20200828194041-157a740278f4

2
go.sum
View file

@ -489,6 +489,8 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/automaxprocs v1.3.0 h1:II28aZoGdaglS5vVNnspf28lnZpXScxtIozx1lAjdb0=
go.uber.org/automaxprocs v1.3.0/go.mod h1:9CWT6lKIep8U41DDaPiH6eFscnTyjfTANNQNx6LrIcA=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=

12
main.go
View file

@ -3,8 +3,18 @@
// https://github.com/drakkan/sftpgo/blob/master/README.md
package main // import "github.com/drakkan/sftpgo"
import "github.com/drakkan/sftpgo/cmd"
import (
"fmt"
"go.uber.org/automaxprocs/maxprocs"
"github.com/drakkan/sftpgo/cmd"
)
func main() {
if undo, err := maxprocs.Set(); err != nil {
fmt.Printf("error setting max procs: %v\n", err)
undo()
}
cmd.Execute()
}