Files
bl/logic/main.go
昔念 174562b895 ```
feat(config): 重构配置结构并添加服务器列表支持

- 重命名PortBL字段为GameOnlineID,改进命名语义
- 添加ServerList结构体用于管理服务器配置
- 移除七牛云配置相关字段
- 更新ID生成器使用GameOnlineID参数

fix(server): 调整服务器启动参数和VIP逻辑

- 将启动参数从-port改为-id,统一参数命名
- 更新服务器启动逻辑,基于GameOnlineID获取服务器信息
- 为VIP服务器启用调试模式
- 优化端口可用性检查逻辑

refactor(model): 统一模型基类结构

- 将各模型中的*cool.Model嵌入改为Base基类
- 移除soul.go
2026-01-08 03:30:18 +08:00

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.GameOnlineID = gcmd.GetOpt("id", "1").Uint16()
go Start() //注入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))
}