Skip to content

Commit a592ca2

Browse files
committed
disable automaxprocs logging
Signed-off-by: nitishfy <[email protected]> fix lint checks Signed-off-by: nitishfy <[email protected]> move maxprocs to main.go Signed-off-by: nitishfy <[email protected]> move set auto max procs to a function Signed-off-by: nitishfy <[email protected]> add info log Signed-off-by: nitishfy <[email protected]>
1 parent fe67cd5 commit a592ca2

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

cmd/main.go

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package main
22

33
import (
4+
log "github.com/sirupsen/logrus"
5+
"go.uber.org/automaxprocs/maxprocs"
46
"os"
57
"path/filepath"
68

79
"github.com/spf13/cobra"
810

9-
_ "go.uber.org/automaxprocs"
10-
1111
appcontroller "github.com/argoproj/argo-cd/v2/cmd/argocd-application-controller/commands"
1212
applicationset "github.com/argoproj/argo-cd/v2/cmd/argocd-applicationset-controller/commands"
1313
cmpserver "github.com/argoproj/argo-cd/v2/cmd/argocd-cmp-server/commands"
@@ -31,6 +31,8 @@ func main() {
3131
if val := os.Getenv(binaryNameEnv); val != "" {
3232
binaryName = val
3333
}
34+
setAutoMaxProcs(binaryName)
35+
3436
switch binaryName {
3537
case "argocd", "argocd-linux-amd64", "argocd-darwin-amd64", "argocd-windows-amd64.exe":
3638
command = cli.NewCommand()
@@ -60,3 +62,21 @@ func main() {
6062
os.Exit(1)
6163
}
6264
}
65+
66+
// setAutoMaxProcs sets the GOMAXPROCS value based on the binary name.
67+
// It suppresses logs for CLI binaries and logs the setting for services.
68+
func setAutoMaxProcs(binaryName string) {
69+
isCLI := binaryName == "argocd" ||
70+
binaryName == "argocd-linux-amd64" ||
71+
binaryName == "argocd-darwin-amd64" ||
72+
binaryName == "argocd-windows-amd64.exe"
73+
74+
if isCLI {
75+
_, _ = maxprocs.Set() // Intentionally ignore errors for CLI binaries
76+
} else {
77+
_, err := maxprocs.Set(maxprocs.Logger(log.Debugf))
78+
if err != nil {
79+
log.Infof("Error setting GOMAXPROCS: %v", err)
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)