on main help sign in
fix: don't supress application level panics
f7ffd8aChristian Rocha
main.go+2−11
@@ -3,23 +3,14 @@ package main
3import (
3import (
4 "log/slog"
4 "log/slog"
5 "net/http"
5 "net/http"
6+ _ "net/http/pprof"
6 "os"
7 "os"
7
8
8− _ "net/http/pprof" // profiling
9−
10− _ "github.com/joho/godotenv/autoload" // automatically load .env files
11−
12 "github.com/charmbracelet/crush/internal/cmd"
9 "github.com/charmbracelet/crush/internal/cmd"
13− "github.com/charmbracelet/crush/internal/event"
10+ _ "github.com/joho/godotenv/autoload"
14− "github.com/charmbracelet/crush/internal/log"
15)
11)
16
12
17func main() {
13func main() {
18− defer log.RecoverPanic("main", func() {
19− event.Flush()
20− slog.Error("Application terminated due to unhandled panic")
21− })
22−
23 if os.Getenv("CRUSH_PROFILE") != "" {
14 if os.Getenv("CRUSH_PROFILE") != "" {
24 go func() {
15 go func() {
25 slog.Info("Serving pprof at localhost:6060")
16 slog.Info("Serving pprof at localhost:6060")