feat(cmd/joj3): log panic stack
Some checks failed
build / build (push) Successful in 1m57s
build / trigger-build-image (push) Successful in 11s
submodules sync / sync (push) Failing after 39s

This commit is contained in:
张泊明518370910136 2025-06-02 22:18:31 -04:00
parent b809488c71
commit f17c742719
GPG Key ID: D47306D7062CDA9D

View File

@ -8,6 +8,7 @@ import (
"io/fs"
"log/slog"
"os"
"runtime/debug"
"strings"
joj3Conf "github.com/joint-online-judge/JOJ3/cmd/joj3/conf"
@ -150,13 +151,20 @@ func main() {
exitCode := 0
defer func() {
if r := recover(); r != nil {
slog.Error("panic recovered", "panic", r)
slog.Error(
"panic recovered",
"panic", r,
"stack", string(debug.Stack()),
)
exitCode = 2
}
if err != nil {
slog.Error("main exit", "error", err)
exitCode = 1
}
if exitCode == 0 {
slog.Info("main exit", "status", "success")
}
os.Exit(exitCode)
}()
err = mainImpl()