feat(build): 更新构建脚本添加资源打包和proto编译 更新build.bat脚本,添加proto文件编译和资源打包功能,调整资源打包顺序。 BREAKING CHANGE: 构建流程发生变化,需要重新生成proto文件和打包资源。 --- refactor(xmlres): 使用gres替换gfile读取资源文件 将xmlres模块中文件读取方式从gfile.GetBytes改为gres.GetContent, 使
89 lines
1.9 KiB
Go
89 lines
1.9 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"runtime"
|
|
"strings"
|
|
|
|
_ "github.com/gogf/gf/contrib/nosql/redis/v2"
|
|
"github.com/gogf/gf/v2/os/gcmd"
|
|
"github.com/gogf/gf/v2/os/gproc"
|
|
|
|
"blazing/logic/service/fight"
|
|
"blazing/logic/service/player"
|
|
|
|
"blazing/cool"
|
|
|
|
//"blazing/o/service"
|
|
"blazing/modules/base/service"
|
|
blservice "blazing/modules/blazing/service"
|
|
"net/http"
|
|
_ "net/http/pprof"
|
|
)
|
|
|
|
// PprofWeb 启动pprof性能分析web服务
|
|
func PprofWeb() {
|
|
runtime.SetMutexProfileFraction(1) // (非必需)开启对锁调用的跟踪
|
|
runtime.SetBlockProfileRate(1) // (非必需)开启对阻塞操作的跟踪
|
|
err := http.ListenAndServe(":9909", nil)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// signalHandlerForMain 主进程信号处理函数
|
|
func signalHandlerForMain(sig os.Signal) {
|
|
fight.Fightpool.ReleaseTimeout(0)
|
|
|
|
player.Mainplayer.Range(func(key uint32, value *player.Player) bool {
|
|
value.Save()
|
|
|
|
return true
|
|
})
|
|
fmt.Println("MainProcess is shutting down due to signal:", sig.String())
|
|
}
|
|
|
|
// main 程序主入口函数
|
|
func main() {
|
|
//loadAccounts()
|
|
// if cool.IsRedisMode {
|
|
// go cool.ListenFunc(gctx.New())
|
|
// }
|
|
// 解析命令行参数
|
|
cool.Config.PortBL = gcmd.GetOpt("port", "1").Uint16()
|
|
go Start(cool.Config.PortBL) //注入service
|
|
// if cool.Config.PortBL == 1 || cool.Config.PortBL == 2 { //只分析1服务器的
|
|
// go PprofWeb()
|
|
// }
|
|
|
|
fmt.Println("Process start, pid:", os.Getpid())
|
|
|
|
gproc.AddSigHandlerShutdown(
|
|
|
|
signalHandlerForMain,
|
|
)
|
|
|
|
gproc.Listen()
|
|
}
|
|
|
|
// loadAccounts 从CSV文件加载账号信息
|
|
func loadAccounts() {
|
|
t1, _ := os.Getwd()
|
|
data, err := os.ReadFile(t1 + "/b.csv")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
lines := strings.Split(string(data), "\n")
|
|
for _, line := range lines {
|
|
line = strings.TrimSpace(line)
|
|
if line == "" {
|
|
continue
|
|
}
|
|
t := service.NewBaseSysUserService().GetEamil(line)
|
|
|
|
blservice.NewUserService(uint32(t.ID)).Info.Reg(t.Username, 0)
|
|
}
|
|
//fmt.Printf("加载 %d 个账号\n", len(accounts))
|
|
}
|