goProject/.svn/pristine/a8/a845322f2fac8ace4b160c406372f0f0d77c2257.svn-base

42 lines
996 B
Plaintext
Raw Normal View History

2025-01-06 16:21:36 +08:00
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))
}
}