on e00a70a help sign in
crush/main.go
31 lines 650 B history raw
1package main
3import (
4 "log/slog"
5 "net/http"
6 "os"
8 _ "net/http/pprof" // profiling
10 _ "github.com/joho/godotenv/autoload" // automatically load .env files
12 "github.com/charmbracelet/crush/internal/cmd"
13 "github.com/charmbracelet/crush/internal/log"
16func main() {
17 defer log.RecoverPanic("main", func() {
18 slog.Error("Application terminated due to unhandled panic")
19 })
21 if os.Getenv("CRUSH_PROFILE") != "" {
22 go func() {
23 slog.Info("Serving pprof at localhost:6060")
24 if httpErr := http.ListenAndServe("localhost:6060", nil); httpErr != nil {
25 slog.Error("Failed to pprof listen", "error", httpErr)
26 }
27 }()
28 }
30 cmd.Execute()