From ea57c6eefc99c7c2381e475b1ecc77d9f9e138c7 Mon Sep 17 00:00:00 2001 From: Evan Han Date: Mon, 28 Nov 2022 14:15:21 +0800 Subject: [PATCH] Merge PR: support pprof and multi-cache when repair state (#2801) * support multi-cache when repair state * add pprof * fix net pprof --- cmd/exchaind/repair_data.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/exchaind/repair_data.go b/cmd/exchaind/repair_data.go index fbf1b9de7a..59615a3a3b 100644 --- a/cmd/exchaind/repair_data.go +++ b/cmd/exchaind/repair_data.go @@ -1,7 +1,10 @@ package main import ( + "fmt" "log" + "net/http" + _ "net/http/pprof" "github.com/okex/exchain/app" "github.com/okex/exchain/app/utils/appstatus" @@ -14,6 +17,7 @@ import ( tmtypes "github.com/okex/exchain/libs/tendermint/types" types2 "github.com/okex/exchain/x/evm/types" "github.com/spf13/cobra" + "github.com/spf13/viper" ) func repairStateCmd(ctx *server.Context) *cobra.Command { @@ -26,6 +30,13 @@ func repairStateCmd(ctx *server.Context) *cobra.Command { Run: func(cmd *cobra.Command, args []string) { log.Println("--------- repair data start ---------") + go func() { + pprofAddress := viper.GetString(pprofAddrFlag) + err := http.ListenAndServe(pprofAddress, nil) + if err != nil { + fmt.Println(err) + } + }() app.RepairState(ctx, false) log.Println("--------- repair data success ---------") }, @@ -37,6 +48,8 @@ func repairStateCmd(ctx *server.Context) *cobra.Command { cmd.Flags().BoolVar(&types2.TrieUseCompositeKey, types2.FlagTrieUseCompositeKey, true, "Use composite key to store contract state") cmd.Flags().Int(sm.FlagDeliverTxsExecMode, 0, "execution mode for deliver txs, (0:serial[default], 1:deprecated, 2:parallel)") cmd.Flags().String(sdk.FlagDBBackend, tmtypes.DBBackend, "Database backend: goleveldb | rocksdb") + cmd.Flags().Bool(sdk.FlagMultiCache, true, "Enable multi cache") + cmd.Flags().StringP(pprofAddrFlag, "p", "0.0.0.0:6060", "Address and port of pprof HTTP server listening") return cmd }