package debug

import (
	"log"
	"net/http"
	"net/http/pprof"
	//"runtime/pprof"
)

type mode int

const (
	// ModeProd 生产模式
	ModeProd mode = 1
	// ModeDev 开发模式
	ModeDev mode = 0
)

// Mode 运行模式
var Mode = ModeDev

// StartHTTPPprof
func StartHTTPPprof(debugaddr string) {
	debugServeMux := http.NewServeMux()
	debugServeMux.Handle("/debug/pprof/", http.HandlerFunc(pprof.Index))
	debugServeMux.Handle("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline))
	debugServeMux.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))
	debugServeMux.Handle("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol))
	debugServeMux.Handle("/debug/pprof/trace", http.HandlerFunc(pprof.Trace))
	go func() {
		log.Fatal(http.ListenAndServe(debugaddr, debugServeMux))
	}()

}
