mirror of
https://github.com/charmbracelet/crush.git
synced 2025-08-02 05:20:46 +03:00
32 lines
650 B
Go
32 lines
650 B
Go
package main
|
|
|
|
import (
|
|
"log/slog"
|
|
"net/http"
|
|
"os"
|
|
|
|
_ "net/http/pprof" // profiling
|
|
|
|
_ "github.com/joho/godotenv/autoload" // automatically load .env files
|
|
|
|
"github.com/charmbracelet/crush/internal/cmd"
|
|
"github.com/charmbracelet/crush/internal/log"
|
|
)
|
|
|
|
func main() {
|
|
defer log.RecoverPanic("main", func() {
|
|
slog.Error("Application terminated due to unhandled panic")
|
|
})
|
|
|
|
if os.Getenv("CRUSH_PROFILE") != "" {
|
|
go func() {
|
|
slog.Info("Serving pprof at localhost:6060")
|
|
if httpErr := http.ListenAndServe("localhost:6060", nil); httpErr != nil {
|
|
slog.Error("Failed to pprof listen", "error", httpErr)
|
|
}
|
|
}()
|
|
}
|
|
|
|
cmd.Execute()
|
|
}
|