feat(cmd/joj3): log panic stack
This commit is contained in:
parent
b809488c71
commit
f17c742719
|
@ -8,6 +8,7 @@ import (
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
joj3Conf "github.com/joint-online-judge/JOJ3/cmd/joj3/conf"
|
joj3Conf "github.com/joint-online-judge/JOJ3/cmd/joj3/conf"
|
||||||
|
@ -150,13 +151,20 @@ func main() {
|
||||||
exitCode := 0
|
exitCode := 0
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
slog.Error("panic recovered", "panic", r)
|
slog.Error(
|
||||||
|
"panic recovered",
|
||||||
|
"panic", r,
|
||||||
|
"stack", string(debug.Stack()),
|
||||||
|
)
|
||||||
exitCode = 2
|
exitCode = 2
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("main exit", "error", err)
|
slog.Error("main exit", "error", err)
|
||||||
exitCode = 1
|
exitCode = 1
|
||||||
}
|
}
|
||||||
|
if exitCode == 0 {
|
||||||
|
slog.Info("main exit", "status", "success")
|
||||||
|
}
|
||||||
os.Exit(exitCode)
|
os.Exit(exitCode)
|
||||||
}()
|
}()
|
||||||
err = mainImpl()
|
err = mainImpl()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user