You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
950 B
Go

3 years ago
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"
3 years ago
)
var configFile = flag.String("f", "./config.yml", "the config file")
3 years ago
func main() {
flag.Parse()
cfg := config.MustLoad(*configFile, config.WithHotReload())
svcCtx := svc.NewServiceContext(context.Background(), cfg)
3 years ago
_ = logger.InitLogger(&cfg.Log.File, &cfg.Log.Console)
defer logger.Sync()
3 years ago
manager.Init(svcCtx)
logic.Init(svcCtx)
live_logic.InitLiveManager(svcCtx)
mq.Init(svcCtx)
3 years ago
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())
3 years ago
}
ngs.Listen(cfg.Server.Listen, opts...)
3 years ago
}