package webServer import ( "fmt" "net/http" "sync" "goutil/logUtil" "goutil/logUtilPlus" "net/http/pprof" config "common/configsYaml" ) // Start // @description: 启动服务器 // parameter: // @wg: WaitGroup对象 // return: func Start(wg *sync.WaitGroup) { defer func() { wg.Done() }() // 启动过程中不需要捕获异常 logUtilPlus.PrintAndWriteLog(logUtil.Warn, fmt.Sprintf("Web服务器开始监听:%v", config.ConfigYaml.Root.WebServerAddress)) // 启动Web服务器监听 mux := http.NewServeMux() mux.Handle("/", &selfDefineMux{}) mux.HandleFunc("/debug/pprof/", pprof.Index) mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline) mux.HandleFunc("/debug/pprof/profile", pprof.Profile) mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol) mux.HandleFunc("/debug/pprof/trace", pprof.Trace) err := http.ListenAndServe(config.ConfigYaml.Root.WebServerAddress, mux) if err != nil { panic(fmt.Errorf("ListenAndServe失败,错误信息为:%s", err)) } }