Skip to content

Commit

Permalink
Added a message when RM is disabled.
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
  • Loading branch information
ajnavarro committed Dec 7, 2022
1 parent 8544f16 commit 682be6b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
13 changes: 12 additions & 1 deletion core/node/libp2p/rcmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ func ResourceManager(cfg config.SwarmConfig) interface{} {
if enabled {
log.Debug("libp2p resource manager is enabled")

// We want to see this message on startup, that's why we are using fmt instead of log.
fmt.Printf(`
Computing default go-libp2p Resource Manager limits based on:
- 'Swarm.ResourceMgr.MaxMemory': %q
- 'Swarm.ResourceMgr.MaxFileDescriptors': %d
Applying any user-supplied overrides on top.
Run 'ipfs swarm limit all' to see the resulting limits.
`, cfg.ResourceMgr.MaxMemory, cfg.ResourceMgr.MaxFileDescriptors)

repoPath, err := config.PathRoot()
if err != nil {
return nil, opts, fmt.Errorf("opening IPFS_PATH: %w", err)
Expand Down Expand Up @@ -112,7 +123,7 @@ func ResourceManager(cfg config.SwarmConfig) interface{} {
lrm.start(helpers.LifecycleCtx(mctx, lc))
manager = lrm
} else {
log.Debug("libp2p resource manager is disabled")
fmt.Println("go-libp2p resource manager protection disabled")
manager = network.NullResourceManager
}

Expand Down
12 changes: 0 additions & 12 deletions core/node/libp2p/rcmgr_defaults.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package libp2p

import (
"fmt"
"math"

"github.com/dustin/go-humanize"
Expand Down Expand Up @@ -57,17 +56,6 @@ func createDefaultLimitConfig(cfg config.SwarmConfig) (rcmgr.LimitConfig, error)

numFD := cfg.ResourceMgr.MaxFileDescriptors.WithDefault(int64(fd.GetNumFDs()) / 2)

// We want to see this message on startup, that's why we are using fmt instead of log.
fmt.Printf(`
Computing default go-libp2p Resource Manager limits based on:
- 'Swarm.ResourceMgr.MaxMemory': %q
- 'Swarm.ResourceMgr.MaxFileDescriptors': %d
Applying any user-supplied overrides on top.
Run 'ipfs swarm limit all' to see the resulting limits.
`, maxMemoryString, numFD)

scalingLimitConfig := rcmgr.ScalingLimitConfig{
SystemBaseLimit: rcmgr.BaseLimit{
Memory: int64(maxMemory),
Expand Down

0 comments on commit 682be6b

Please sign in to comment.