Skip to content

Commit

Permalink
Merge PR: support pprof and multi-cache when repair state (#2801)
Browse files Browse the repository at this point in the history
* support multi-cache when repair state

* add pprof

* fix net pprof
  • Loading branch information
ilovers authored Nov 28, 2022
1 parent cf81f29 commit ea57c6e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/exchaind/repair_data.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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 {
Expand All @@ -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 ---------")
},
Expand All @@ -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
}
Expand Down

0 comments on commit ea57c6e

Please sign in to comment.