Skip to content

Commit

Permalink
Merge pull request #497 from oasisprotocol/ptrus/feature/pprof-support
Browse files Browse the repository at this point in the history
pprof support
  • Loading branch information
ptrus authored Dec 21, 2023
2 parents b234336 + 5b9c003 commit dbd5b18
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type Config struct {
// with it's own SQL database instance, this parameter should not
// be needed.
ArchiveHeightMax uint64 `koanf:"archive_height_max"`

PprofAddr string `koanf:"pprof_addr"`
}

// Validate performs config validation.
Expand Down
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package main
import (
"context"
"fmt"
"net/http"
_ "net/http/pprof" // nolint:gosec,G108
"os"
"os/signal"
"syscall"
Expand Down Expand Up @@ -172,6 +174,15 @@ func runRoot() error {
return err
}

// Enable pprof if configured.
if cfg.PprofAddr != "" {
go func() {
if err = http.ListenAndServe(cfg.PprofAddr, nil); err != nil { // nolint:gosec,G114
logging.GetLogger("pprof").Error("server stopped", "err", err)
}
}()
}

logger := logging.GetLogger("main")

// Decode hex runtime ID into something we can use.
Expand Down

0 comments on commit dbd5b18

Please sign in to comment.