goProject/.svn/pristine/8e/8e4d6a36cddbce2fb52c50f65c2debf471676f59.svn-base
2025-01-06 16:21:36 +08:00

43 lines
975 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package httpServer
import (
"fmt"
"net/http"
"sync"
"goutil/logUtil"
"goutil/logUtilPlus"
// "log"
"net/http/pprof"
config "common/configsYaml"
)
// Start
// @description: 启动服务器
// parameter:
// @wg: WaitGroup对象
// return:
func Start(wg *sync.WaitGroup) {
defer func() {
wg.Done()
}()
// 启动过程中不需要捕获异常
logUtilPlus.PrintAndWriteLog(logUtil.Info, fmt.Sprintf("Web服务器开始监听:%v", config.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.WebServerAddress, mux)
if err != nil {
panic(fmt.Errorf("ListenAndServe失败错误信息为%s", err))
}
}