main.go

 1package main
 2
 3import (
 4	"net/http"
 5	"os"
 6
 7	_ "net/http/pprof" // profiling
 8
 9	_ "github.com/joho/godotenv/autoload" // automatically load .env files
10
11	"github.com/charmbracelet/crush/cmd"
12	"github.com/charmbracelet/crush/internal/logging"
13)
14
15func main() {
16	defer logging.RecoverPanic("main", func() {
17		logging.ErrorPersist("Application terminated due to unhandled panic")
18	})
19
20	if os.Getenv("CRUSH_PROFILE") != "" {
21		go func() {
22			logging.Info("Serving pprof at localhost:6060")
23			if httpErr := http.ListenAndServe("localhost:6060", nil); httpErr != nil {
24				logging.Error("Failed to pprof listen: %v", httpErr)
25			}
26		}()
27	}
28
29	cmd.Execute()
30}