From 87afc18cfd1c0e5edbccceda1b3cddc8d9e8e6d3 Mon Sep 17 00:00:00 2001 From: Alex Sharov <AskAlexSharov@gmail.com> Date: Sat, 11 Sep 2021 16:25:21 +0700 Subject: [PATCH] increase fdlimit from all binaries (#2665) (not only rpcdaemon) --- cmd/rpcdaemon/main.go | 14 -------------- internal/debug/flags.go | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/cmd/rpcdaemon/main.go b/cmd/rpcdaemon/main.go index 170c38954e..9e71247a2c 100644 --- a/cmd/rpcdaemon/main.go +++ b/cmd/rpcdaemon/main.go @@ -7,13 +7,11 @@ import ( "github.com/ledgerwatch/erigon/cmd/rpcdaemon/commands" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/filters" "github.com/ledgerwatch/erigon/cmd/utils" - "github.com/ledgerwatch/erigon/common/fdlimit" "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) func main() { - raiseFdLimit() cmd, cfg := cli.RootCommand() rootCtx, rootCancel := utils.RootContext() cmd.RunE = func(cmd *cobra.Command, args []string) error { @@ -44,15 +42,3 @@ func main() { os.Exit(1) } } - -// raiseFdLimit raises out the number of allowed file handles per process -func raiseFdLimit() { - limit, err := fdlimit.Maximum() - if err != nil { - log.Error("Failed to retrieve file descriptor allowance", "error", err) - return - } - if _, err = fdlimit.Raise(uint64(limit)); err != nil { - log.Error("Failed to raise file descriptor allowance", "error", err) - } -} diff --git a/internal/debug/flags.go b/internal/debug/flags.go index b99d1cd0ee..ff70736606 100644 --- a/internal/debug/flags.go +++ b/internal/debug/flags.go @@ -26,6 +26,7 @@ import ( "syscall" metrics2 "github.com/VictoriaMetrics/metrics" + "github.com/ledgerwatch/erigon/common/fdlimit" "github.com/ledgerwatch/erigon/metrics" "github.com/ledgerwatch/erigon/metrics/exp" "github.com/ledgerwatch/log/v3" @@ -114,6 +115,7 @@ func init() { } func SetupCobra(cmd *cobra.Command) error { + raiseFdLimit() flags := cmd.Flags() lvl, err := flags.GetInt(verbosityFlag.Name) if err != nil { @@ -214,6 +216,7 @@ func SetupCobra(cmd *cobra.Command) error { // Setup initializes profiling and logging based on the CLI flags. // It should be called as early as possible in the program. func Setup(ctx *cli.Context) error { + raiseFdLimit() //var ostream log.Handler //output := io.Writer(os.Stderr) if ctx.GlobalBool(logjsonFlag.Name) { @@ -297,3 +300,15 @@ func Exit() { _ = Handler.StopCPUProfile() _ = Handler.StopGoTrace() } + +// raiseFdLimit raises out the number of allowed file handles per process +func raiseFdLimit() { + limit, err := fdlimit.Maximum() + if err != nil { + log.Error("Failed to retrieve file descriptor allowance", "error", err) + return + } + if _, err = fdlimit.Raise(uint64(limit)); err != nil { + log.Error("Failed to raise file descriptor allowance", "error", err) + } +} -- GitLab