Skip to content

Commit

Permalink
feat: add Profiler if DEBUG is enabled (port 10001)
Browse files Browse the repository at this point in the history
  • Loading branch information
Apoorva64 committed Jul 17, 2024
1 parent eceb17b commit ae8fc6f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit ae8fc6f

Please sign in to comment.