on 9c79c19 help sign in
crush/main.go
32 lines 656 B history raw
1package main
3import (
4 "fmt"
5 "log/slog"
6 "net/http"
7 "os"
9 _ "net/http/pprof" // profiling
11 _ "github.com/joho/godotenv/autoload" // automatically load .env files
13 "github.com/charmbracelet/crush/cmd"
14 "github.com/charmbracelet/crush/internal/log"
17func main() {
18 defer log.RecoverPanic("main", func() {
19 slog.Error("Application terminated due to unhandled panic")
20 })
22 if os.Getenv("CRUSH_PROFILE") != "" {
23 go func() {
24 slog.Info("Serving pprof at localhost:6060")
25 if httpErr := http.ListenAndServe("localhost:6060", nil); httpErr != nil {
26 slog.Error(fmt.Sprintf("Failed to pprof listen: %v", httpErr))
27 }
28 }()
29 }
31 cmd.Execute()