mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 11:41:19 +00:00
a63b89334b
Changed distribution of httpcfg.HttpCfg to be pointer. Added new flags: rpc.slow.log - which is false by default, this flag need to enable logging slow RPC requests rpc.slow.log.threshold - which is 100 by default, this flag specify slow threshold in milliseconds Updated rpc handler to log slow requests: - added map[request id] {method, timestamp} - put every request details to map above - delete request details from map above - added time interval check for elements in map and if time difference is more than given threshold print request id and the method - app will print slow requests in next cases: 1. As soon as request take more than given threshold 2. Every 20 seconds if request still in process 3. After request finished and it took more than give threshold --------- Co-authored-by: alex.sharov <AskAlexSharov@gmail.com>
48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/ledgerwatch/erigon-lib/common"
|
|
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli"
|
|
"github.com/ledgerwatch/erigon/rpc"
|
|
"github.com/ledgerwatch/erigon/turbo/debug"
|
|
"github.com/ledgerwatch/erigon/turbo/jsonrpc"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func main() {
|
|
cmd, cfg := cli.RootCommand()
|
|
rootCtx, rootCancel := common.RootContext()
|
|
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
|
ctx := cmd.Context()
|
|
logger := debug.SetupCobra(cmd, "sentry")
|
|
db, backend, txPool, mining, stateCache, blockReader, engine, ff, agg, err := cli.RemoteServices(ctx, cfg, logger, rootCancel)
|
|
if err != nil {
|
|
if !errors.Is(err, context.Canceled) {
|
|
logger.Error("Could not connect to DB", "err", err)
|
|
}
|
|
return nil
|
|
}
|
|
defer db.Close()
|
|
defer engine.Close()
|
|
|
|
apiList := jsonrpc.APIList(db, backend, txPool, mining, ff, stateCache, blockReader, agg, cfg, engine, logger)
|
|
rpc.PreAllocateRPCMetricLabels(apiList)
|
|
if err := cli.StartRpcServer(ctx, cfg, apiList, logger); err != nil {
|
|
logger.Error(err.Error())
|
|
return nil
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
if err := cmd.ExecuteContext(rootCtx); err != nil {
|
|
fmt.Printf("ExecuteContext: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|