Skip to content

Commit

Permalink
chore: Configurable LOTUS_PANIC_JOURNAL_LOOKBACK
Browse files Browse the repository at this point in the history
  • Loading branch information
placer14 committed Sep 17, 2021
1 parent 3508a5b commit ccf24b9
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions build/panic_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@ import (
"path/filepath"
"runtime/debug"
"runtime/pprof"
"strconv"
"syscall"
"time"

"github.com/icza/backscanner"
logging "github.com/ipfs/go-log/v2"
)

var panicLog = logging.Logger("panic-reporter")
var (
panicLog = logging.Logger("panic-reporter")
defaultJournalTail = 500
)

// PanicReportingPath is the name of the subdir created within the repoPath path
// provided to GeneratePanicReport
var PanicReportingPath = "lotus_panic_reports"
var PanicReportingPath = "lotus-panic-reports"

// PanicReportJournalTail is the number of lines captured from the end of
// the lotus journal to be included in the panic report.
var PanicReportJournalTail = 500
var PanicReportJournalTail = defaultJournalTail

// GeneratePanicReport produces a timestamped dump of the application state
// for inspection and debugging purposes. Call this function from any place
Expand All @@ -39,6 +43,14 @@ func GeneratePanicReport(persistPath, repoPath, label string) {
panicLog.Error("persist path is empty, aborting panic report generation")
return
}
tl := os.Getenv("LOTUS_PANIC_JOURNAL_LOOKBACK")
if tl != "" && PanicReportJournalTail == defaultJournalTail {
i, err := strconv.Atoi(tl)
if err == nil {
PanicReportJournalTail = i
}
}

reportPath := filepath.Join(persistPath, PanicReportingPath, generateReportName(label))
panicLog.Warnf("generating panic report at %s", reportPath)
syscall.Umask(0)
Expand Down

0 comments on commit ccf24b9

Please sign in to comment.