main.go 575 B

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