Skip to content

Commit

Permalink
fix: enable pprof (#1380)
Browse files Browse the repository at this point in the history
  • Loading branch information
V-Staykov authored Oct 30, 2024
1 parent 620a26e commit 35ef74c
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/cdk-erigon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func main() {
*/
}()

app := erigonapp.MakeApp("cdk-erigon", runErigon, erigoncli.DefaultFlags)
app := erigonapp.MakeApp_zkEvm("cdk-erigon", runErigon, erigoncli.DefaultFlags)
if err := app.Run(os.Args); err != nil {
_, printErr := fmt.Fprintln(os.Stderr, err)
if printErr != nil {
Expand Down
66 changes: 66 additions & 0 deletions turbo/app/make_app_zkevm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Package app contains framework for building a command-line based Erigon node.
package app

import (
"fmt"

"github.com/ledgerwatch/log/v3"
"github.com/urfave/cli/v2"

"github.com/ledgerwatch/erigon/cmd/utils"
"github.com/ledgerwatch/erigon/params"
cli2 "github.com/ledgerwatch/erigon/turbo/cli"
"github.com/ledgerwatch/erigon/turbo/debug"
)

// MakeApp creates a cli application (based on `github.com/urlfave/cli` package).
// The application exits when `action` returns.
// Parameters:
// * action: the main function for the application. receives `*cli.Context` with parsed command-line flags.
// * cliFlags: the list of flags `cli.Flag` that the app should set and parse. By default, use `DefaultFlags()`. If you want to specify your own flag, use `append(DefaultFlags(), myFlag)` for this parameter.
func MakeApp_zkEvm(name string, action cli.ActionFunc, cliFlags []cli.Flag) *cli.App {
app := cli2.NewApp(params.GitCommit, "erigon")
app.Name = name
app.UsageText = app.Name + ` [command] [flags]`
app.Action = func(context *cli.Context) error {
// handle case: unknown sub-command
if context.Args().Present() {
var goodNames []string
for _, c := range app.VisibleCommands() {
goodNames = append(goodNames, c.Name)
}
log.Error(fmt.Sprintf("Command '%s' not found. Available commands: %s", context.Args().First(), goodNames))
cli.ShowAppHelpAndExit(context, 1)
}

// handle case: config flag
configFilePath := context.String(utils.ConfigFlag.Name)
if configFilePath != "" {
if err := cli2.SetFlagsFromConfigFile(context, configFilePath); err != nil {
log.Error("failed setting config flags from yaml/toml file", "err", err)
return err
}
}

// run default action
return action(context)
}

app.Flags = appFlags(cliFlags)
app.Before = func(ctx *cli.Context) error {
_, _, _, err := debug.Setup(ctx, true)
return err
}
app.After = func(ctx *cli.Context) error {
debug.Exit()
return nil
}
app.Commands = []*cli.Command{
&initCommand,
&importCommand,
&snapshotCommand,
&supportCommand,
//&backupCommand,
}
return app
}

0 comments on commit 35ef74c

Please sign in to comment.