pprof监控

参考学习视频

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main

import (
	"flag"
	"github.com/spf13/viper"
	"log"
	"myproxyHttp/config"
	"myproxyHttp/httpproxy"
	"myproxyHttp/tcpproxy"
	"net/http"
	_ "net/http/pprof"
	"time"
)

func main() {
	cconf := *flag.String("conf", "conf", "configFile path")
	//fmt.Println("hello world")
	flag.Parse()
	config.Load(cconf)
	//httpproxy.Simple1()
	//开启tcp代理
	log.Printf("init done\n")

	pprofOpen := viper.GetBool("pprof")
	if pprofOpen {
		http.ListenAndServe(":80", nil)
	}
	for {
		time.Sleep(time.Hour)
	}
}