|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"dcg/config"
|
|
|
|
"dcg/game/live_logic"
|
|
|
|
"dcg/game/logic"
|
|
|
|
"dcg/game/manager"
|
|
|
|
"dcg/game/mq"
|
|
|
|
"dcg/game/svc"
|
|
|
|
"flag"
|
|
|
|
"git.noahlan.cn/northlan/ngs"
|
|
|
|
"git.noahlan.cn/northlan/ngs/serialize/protobuf"
|
|
|
|
"git.noahlan.cn/northlan/ntools-go/logger"
|
|
|
|
)
|
|
|
|
|
|
|
|
var configFile = flag.String("f", "./config.yml", "the config file")
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
cfg := config.MustLoad(*configFile, config.WithHotReload())
|
|
|
|
|
|
|
|
svcCtx := svc.NewServiceContext(context.Background(), cfg)
|
|
|
|
|
|
|
|
_ = logger.InitLogger(&cfg.Log.File, &cfg.Log.Console)
|
|
|
|
defer logger.Sync()
|
|
|
|
|
|
|
|
manager.Init(svcCtx)
|
|
|
|
logic.Init(svcCtx)
|
|
|
|
live_logic.InitLiveManager(svcCtx)
|
|
|
|
|
|
|
|
mq.Init(svcCtx)
|
|
|
|
|
|
|
|
opts := make([]ngs.Option, 0)
|
|
|
|
opts = append(opts, ngs.WithComponents(logic.GameLogic.Services))
|
|
|
|
opts = append(opts, ngs.WithSerializer(protobuf.NewSerializer()))
|
|
|
|
if cfg.Server.Debug {
|
|
|
|
opts = append(opts, ngs.WithDebugMode())
|
|
|
|
}
|
|
|
|
|
|
|
|
ngs.Listen(cfg.Server.Listen, opts...)
|
|
|
|
}
|