Apply .gitignore rules

This commit is contained in:
皮蛋13361098506
2025-01-06 16:21:36 +08:00
parent 1b77f62820
commit ccd2c530cf
580 changed files with 69806 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
package initMgr
import (
"fmt"
"sync"
"goutil/debugUtil"
"goutil/logUtil"
)
// 初始化成功对象
type InitSuccess struct {
name string
registerMap map[string]chan bool
mutex sync.RWMutex
}
// 注册需要被通知的对象
// name:唯一标识
// ch:用于通知的通道
func (this *InitSuccess) Register(name string, ch chan bool) {
this.mutex.Lock()
defer this.mutex.Unlock()
if _, exists := this.registerMap[name]; exists {
panic(fmt.Errorf("InitSuccess.Register-%s-%s已经存在请检查", this.name, name))
}
this.registerMap[name] = ch
logUtil.DebugLog(fmt.Sprintf("InitSuccess.Register-%s当前共有%d个注册", this.name, len(this.registerMap)))
}
// 取消启动成功通知注册
// name:唯一标识
func (this *InitSuccess) Unregister(name string) {
this.mutex.Lock()
defer this.mutex.Unlock()
delete(this.registerMap, name)
}
// 通知所有已注册的对象
func (this *InitSuccess) Notify() {
this.mutex.RLock()
defer this.mutex.RUnlock()
for name, ch := range this.registerMap {
ch <- true
msg := fmt.Sprintf("通知:%s-%s初始化成功", this.name, name)
debugUtil.Println(msg)
logUtil.DebugLog(msg)
}
}
// 创建初始化成功对象
func NewInitSuccess(name string) *InitSuccess {
return &InitSuccess{
name: name,
registerMap: make(map[string]chan bool),
}
}

View File

@@ -0,0 +1,41 @@
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))
}
}