Skip to content

Commit

Permalink
all: Use own automaxprocs package that doesn't log (ref #9436) (#9437)
Browse files Browse the repository at this point in the history
### Purpose

🤫
  • Loading branch information
calmh committed Feb 27, 2024
1 parent aa559bf commit 07a9fa2
Show file tree
Hide file tree
Showing 20 changed files with 37 additions and 22 deletions.
2 changes: 1 addition & 1 deletion build.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import (
"text/template"
"time"

_ "github.com/syncthing/syncthing/lib/automaxprocs"
buildpkg "github.com/syncthing/syncthing/lib/build"
_ "go.uber.org/automaxprocs"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/stcompdirs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"os"
"path/filepath"

_ "github.com/syncthing/syncthing/lib/automaxprocs"
"github.com/syncthing/syncthing/lib/sha256"
_ "go.uber.org/automaxprocs"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/stcrashreceiver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
"github.com/alecthomas/kong"
raven "github.com/getsentry/raven-go"
"github.com/prometheus/client_golang/prometheus/promhttp"
_ "github.com/syncthing/syncthing/lib/automaxprocs"
"github.com/syncthing/syncthing/lib/sha256"
"github.com/syncthing/syncthing/lib/ur"
_ "go.uber.org/automaxprocs"
)

const maxRequestSize = 1 << 20 // 1 MiB
Expand Down
2 changes: 1 addition & 1 deletion cmd/stdisco/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (
"strings"
"time"

_ "github.com/syncthing/syncthing/lib/automaxprocs"
"github.com/syncthing/syncthing/lib/beacon"
"github.com/syncthing/syncthing/lib/discover"
"github.com/syncthing/syncthing/lib/protocol"
_ "go.uber.org/automaxprocs"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/stdiscosrv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import (
"time"

"github.com/prometheus/client_golang/prometheus/promhttp"
_ "github.com/syncthing/syncthing/lib/automaxprocs"
"github.com/syncthing/syncthing/lib/build"
"github.com/syncthing/syncthing/lib/protocol"
"github.com/syncthing/syncthing/lib/tlsutil"
"github.com/syndtr/goleveldb/leveldb/opt"
"github.com/thejerf/suture/v4"
_ "go.uber.org/automaxprocs"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion cmd/stevents/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"os"
"time"

_ "go.uber.org/automaxprocs"
_ "github.com/syncthing/syncthing/lib/automaxprocs"
)

type event struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/stfileinfo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"os"
"path/filepath"

_ "github.com/syncthing/syncthing/lib/automaxprocs"
"github.com/syncthing/syncthing/lib/protocol"
"github.com/syncthing/syncthing/lib/scanner"
_ "go.uber.org/automaxprocs"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/stfinddevice/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import (
"os"
"time"

_ "github.com/syncthing/syncthing/lib/automaxprocs"
"github.com/syncthing/syncthing/lib/config"
"github.com/syncthing/syncthing/lib/discover"
"github.com/syncthing/syncthing/lib/events"
"github.com/syncthing/syncthing/lib/protocol"
_ "go.uber.org/automaxprocs"
)

var timeout = 5 * time.Second
Expand Down
2 changes: 1 addition & 1 deletion cmd/stfindignored/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"fmt"
"os"

_ "github.com/syncthing/syncthing/lib/automaxprocs"
"github.com/syncthing/syncthing/lib/fs"
"github.com/syncthing/syncthing/lib/ignore"
_ "go.uber.org/automaxprocs"
)

func main() {
Expand Down
6 changes: 3 additions & 3 deletions cmd/stgenfiles/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"path/filepath"
"time"

_ "go.uber.org/automaxprocs"
_ "github.com/syncthing/syncthing/lib/automaxprocs"
)

func main() {
Expand Down Expand Up @@ -45,7 +45,7 @@ func generateFiles(dir string, files, maxexp int, srcname string) error {
}

p0 := filepath.Join(dir, string(n[0]), n[0:2])
err = os.MkdirAll(p0, 0755)
err = os.MkdirAll(p0, 0o755)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -84,7 +84,7 @@ func generateOneFile(fd io.ReadSeeker, p1 string, s int64) error {
return err
}

os.Chmod(p1, os.FileMode(rand.Intn(0777)|0400))
os.Chmod(p1, os.FileMode(rand.Intn(0o777)|0o400))

t := time.Now().Add(-time.Duration(rand.Intn(30*86400)) * time.Second)
return os.Chtimes(p1, t, t)
Expand Down
2 changes: 1 addition & 1 deletion cmd/strelaypoolsrv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/syncthing/syncthing/cmd/strelaypoolsrv/auto"
"github.com/syncthing/syncthing/lib/assets"
_ "github.com/syncthing/syncthing/lib/automaxprocs"
"github.com/syncthing/syncthing/lib/httpcache"
"github.com/syncthing/syncthing/lib/protocol"
"github.com/syncthing/syncthing/lib/rand"
"github.com/syncthing/syncthing/lib/relay/client"
"github.com/syncthing/syncthing/lib/sync"
"github.com/syncthing/syncthing/lib/tlsutil"
_ "go.uber.org/automaxprocs"
)

type location struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/strelaysrv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"syscall"
"time"

_ "github.com/syncthing/syncthing/lib/automaxprocs"
"github.com/syncthing/syncthing/lib/build"
"github.com/syncthing/syncthing/lib/config"
"github.com/syncthing/syncthing/lib/events"
Expand All @@ -29,7 +30,6 @@ import (
"github.com/syncthing/syncthing/lib/relay/protocol"
"github.com/syncthing/syncthing/lib/tlsutil"
_ "github.com/syncthing/syncthing/lib/upnp"
_ "go.uber.org/automaxprocs"
"golang.org/x/time/rate"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/strelaysrv/testutil/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
"path/filepath"
"time"

_ "github.com/syncthing/syncthing/lib/automaxprocs"
syncthingprotocol "github.com/syncthing/syncthing/lib/protocol"
"github.com/syncthing/syncthing/lib/relay/client"
"github.com/syncthing/syncthing/lib/relay/protocol"
_ "go.uber.org/automaxprocs"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/stsigtool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"log"
"os"

_ "github.com/syncthing/syncthing/lib/automaxprocs"
"github.com/syncthing/syncthing/lib/signature"
"github.com/syncthing/syncthing/lib/upgrade"
_ "go.uber.org/automaxprocs"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/stupgrades/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
"time"

"github.com/alecthomas/kong"
_ "github.com/syncthing/syncthing/lib/automaxprocs"
"github.com/syncthing/syncthing/lib/httpcache"
"github.com/syncthing/syncthing/lib/upgrade"
_ "go.uber.org/automaxprocs"
)

type cli struct {
Expand Down
4 changes: 2 additions & 2 deletions cmd/stvanity/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"sync/atomic"
"time"

_ "github.com/syncthing/syncthing/lib/automaxprocs"
"github.com/syncthing/syncthing/lib/protocol"
_ "go.uber.org/automaxprocs"
)

type result struct {
Expand Down Expand Up @@ -158,7 +158,7 @@ func saveCert(priv interface{}, derBytes []byte) {
os.Exit(1)
}

keyOut, err := os.OpenFile("key.pem", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
keyOut, err := os.OpenFile("key.pem", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600)
if err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion cmd/stwatchfile/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"os"
"time"

_ "github.com/syncthing/syncthing/lib/automaxprocs"
"github.com/syncthing/syncthing/lib/sha256"
_ "go.uber.org/automaxprocs"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/syncthing/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import (
"time"

"github.com/alecthomas/kong"
_ "github.com/syncthing/syncthing/lib/automaxprocs"
"github.com/thejerf/suture/v4"
"github.com/willabides/kongplete"
_ "go.uber.org/automaxprocs"

"github.com/syncthing/syncthing/cmd/syncthing/cli"
"github.com/syncthing/syncthing/cmd/syncthing/cmdutil"
Expand Down
2 changes: 1 addition & 1 deletion cmd/ursrv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/alecthomas/kong"
"github.com/syncthing/syncthing/cmd/ursrv/aggregate"
"github.com/syncthing/syncthing/cmd/ursrv/serve"
_ "go.uber.org/automaxprocs"
_ "github.com/syncthing/syncthing/lib/automaxprocs"
)

type CLI struct {
Expand Down
15 changes: 15 additions & 0 deletions lib/automaxprocs/automaxprocs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (C) 2024 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.

package automaxprocs

import (
"go.uber.org/automaxprocs/maxprocs"
)

func init() {
maxprocs.Set()
}

0 comments on commit 07a9fa2

Please sign in to comment.