2022-11-18 15:21:15 +01:00
|
|
|
package internal
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/go-logr/logr"
|
|
|
|
"go.uber.org/automaxprocs/maxprocs"
|
|
|
|
)
|
|
|
|
|
2023-04-11 19:44:49 +02:00
|
|
|
func setupMaxProcs(logger logr.Logger) func() {
|
2022-11-18 15:21:15 +01:00
|
|
|
logger = logger.WithName("maxprocs")
|
2022-11-23 08:28:19 +01:00
|
|
|
logger.Info("setup maxprocs...")
|
2022-11-18 15:21:15 +01:00
|
|
|
undo, err := maxprocs.Set(
|
|
|
|
maxprocs.Logger(
|
|
|
|
func(format string, args ...interface{}) {
|
|
|
|
logger.Info(fmt.Sprintf(format, args...))
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
2023-06-19 18:27:00 +02:00
|
|
|
if err != nil {
|
|
|
|
logger.Error(err, "failed to configure maxprocs")
|
|
|
|
}
|
2022-11-18 15:21:15 +01:00
|
|
|
return undo
|
|
|
|
}
|