diff --git a/cmd/main.go b/cmd/main.go index b464e19..5eec7cd 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -13,16 +13,28 @@ import ( "google.golang.org/grpc/credentials/insecure" "net" "net/http" + _ "net/http/pprof" "os" ) +func startDebug() { + log.Println("Starting pprof server on " + ":10001") + err := http.ListenAndServe(":10001", nil) + if err != nil { + log.Fatal("failed to start pprof server: ", err) + } + +} + func main() { ctx := context.Background() err := godotenv.Load() if err != nil { log.Warnf("Error loading .env file") } - + if os.Getenv("DEBUG") == "true" { + go startDebug() + } host := "localhost" if os.Getenv("HOST") != "" { host = os.Getenv("HOST")