浏览代码

pprof for dev

DarthSim 6 年之前
父节点
当前提交
21e4029a05
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      main.go

+ 7 - 0
main.go

@@ -4,6 +4,7 @@ import (
 	"os"
 	"os"
 	"os/signal"
 	"os/signal"
 
 
+	"net/http"
 	_ "net/http/pprof"
 	_ "net/http/pprof"
 )
 )
 
 
@@ -12,6 +13,12 @@ const version = "2.0.1"
 type ctxKey string
 type ctxKey string
 
 
 func main() {
 func main() {
+	if len(os.Getenv("IMGPROXY_PPROF_BIND")) > 0 {
+		go func() {
+			http.ListenAndServe(os.Getenv("IMGPROXY_PPROF_BIND"), nil)
+		}()
+	}
+
 	s := startServer()
 	s := startServer()
 
 
 	stop := make(chan os.Signal, 1)
 	stop := make(chan os.Signal, 1)