@@ -28,13 +28,31 @@ var PanicReportingPath = "panic-reports"
28
28
// the lotus journal to be included in the panic report.
29
29
var PanicReportJournalTail = defaultJournalTail
30
30
31
- // GeneratePanicReport produces a timestamped dump of the application state
31
+ // GenerateNodePanicReport produces a timestamped dump of the application state
32
32
// for inspection and debugging purposes. Call this function from any place
33
33
// where a panic or severe error needs to be examined. `persistPath` is the
34
34
// path where the reports should be saved. `repoPath` is the path where the
35
35
// journal should be read from. `label` is an optional string to include
36
36
// next to the report timestamp.
37
- func GeneratePanicReport (persistPath , repoPath , label string ) {
37
+ //
38
+ // This function should be called for panics originating from the Lotus daemon.
39
+ func GenerateNodePanicReport (persistPath , repoPath , label string ) {
40
+ generatePanicReport (NodeUserVersion (), persistPath , repoPath , label )
41
+ }
42
+
43
+ // GenerateMinerPanicReport produces a timestamped dump of the application state
44
+ // for inspection and debugging purposes. Call this function from any place
45
+ // where a panic or severe error needs to be examined. `persistPath` is the
46
+ // path where the reports should be saved. `repoPath` is the path where the
47
+ // journal should be read from. `label` is an optional string to include
48
+ // next to the report timestamp.
49
+ //
50
+ // This function should be called for panics originating from the Lotus miner.
51
+ func GenerateMinerPanicReport (persistPath , repoPath , label string ) {
52
+ generatePanicReport (MinerUserVersion (), persistPath , repoPath , label )
53
+ }
54
+
55
+ func generatePanicReport (buildVersion BuildVersion , persistPath , repoPath , label string ) {
38
56
// make sure we always dump the latest logs on the way out
39
57
// especially since we're probably panicking
40
58
defer panicLog .Sync () //nolint:errcheck
@@ -64,21 +82,21 @@ func GeneratePanicReport(persistPath, repoPath, label string) {
64
82
return
65
83
}
66
84
67
- writeAppVersion (filepath .Join (reportPath , "version" ))
85
+ writeAppVersion (buildVersion , filepath .Join (reportPath , "version" ))
68
86
writeStackTrace (filepath .Join (reportPath , "stacktrace.dump" ))
69
87
writeProfile ("goroutines" , filepath .Join (reportPath , "goroutines.pprof.gz" ))
70
88
writeProfile ("heap" , filepath .Join (reportPath , "heap.pprof.gz" ))
71
89
writeJournalTail (PanicReportJournalTail , repoPath , filepath .Join (reportPath , "journal.ndjson" ))
72
90
}
73
91
74
- func writeAppVersion (file string ) {
92
+ func writeAppVersion (buildVersion BuildVersion , file string ) {
75
93
f , err := os .Create (file )
76
94
if err != nil {
77
95
panicLog .Error (err .Error ())
78
96
}
79
97
defer f .Close () //nolint:errcheck
80
98
81
- versionString := []byte (BuildVersion + BuildTypeString () + CurrentCommit + "\n " )
99
+ versionString := []byte (string ( buildVersion ) + BuildTypeString () + CurrentCommit + "\n " )
82
100
if _ , err := f .Write (versionString ); err != nil {
83
101
panicLog .Error (err .Error ())
84
102
}
0 commit comments