Skip to content

Commit

Permalink
write rcmgr to file when IPFS_DEBUG_RCMGR is set
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Mar 11, 2022
1 parent d23a188 commit 33fbdbf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/node/libp2p/rcmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"context"
"errors"
"fmt"
"os"

"github.com/ipfs/go-ipfs/repo"
"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p-core/network"
rcmgr "github.com/libp2p/go-libp2p-resource-manager"
"go.uber.org/fx"
"os"
)

const NetLimitDefaultFilename = "limit.json"
Expand Down Expand Up @@ -38,7 +39,12 @@ func ResourceManager() func(fx.Lifecycle, repo.Repo) (network.ResourceManager, L

libp2p.SetDefaultServiceLimits(limiter)

rcmgr, err := rcmgr.NewResourceManager(limiter)
var ropts []rcmgr.Option
if os.Getenv("IPFS_DEBUG_RCMGR") != "" {
ropts = append(ropts, rcmgr.WithTrace("rcmgr.json.gz"))
}

rcmgr, err := rcmgr.NewResourceManager(limiter, ropts...)
if err != nil {
return nil, opts, fmt.Errorf("error creating resource manager: %w", err)
}
Expand Down

0 comments on commit 33fbdbf

Please sign in to comment.