pet_home_server/src/server/main.go

45 lines
988 B
Go
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 main
import (
"fmt"
"net/http"
_ "net/http/pprof"
"runtime"
"runtime/debug"
"server/conf"
"server/game"
"server/gate"
"server/pkg/github.com/name5566/leaf"
lconf "server/pkg/github.com/name5566/leaf/conf"
)
func main() {
// 设置使用所有 CPU 核心
runtime.GOMAXPROCS(runtime.NumCPU())
lconf.LogLevel = conf.Server.LogLevel
lconf.LogPath = conf.Server.LogPath
lconf.LogFlag = conf.LogFlag
lconf.ConsolePort = conf.Server.ConsolePort
lconf.ProfilePath = conf.Server.ProfilePath
lconf.ListenAddr = conf.Server.ListenAddr
lconf.CenterAddr = conf.Server.CenterAddr
lconf.PendingWriteNum = conf.PendingWriteNum
// 当内存>256M时开始GC
debug.SetGCPercent(50)
debug.SetMemoryLimit(512 << 20)
// 启动 pprof仅绑定本地
go func() {
// 如果需要绑定所有接口改为 ":6060"
port := 6060 + conf.Server.ServerID
_ = http.ListenAndServe(fmt.Sprintf("127.0.0.1:%d", port), nil)
}()
leaf.Run(
game.Module,
gate.Module,
)
}