package main import ( "github.com/gin-gonic/gin" "github.com/mhaya" mhayaGin "github.com/mhaya/components/gin" mhayaMongo "github.com/mhaya/components/mongo" "github.com/mhaya/game/game_cluster/internal/data" "github.com/mhaya/game/game_cluster/internal/mdb" "github.com/mhaya/game/game_cluster/nodes/adminapi/router" ) func main() { // 配置mhaya引擎,加载profile配置文件 app := mhaya.Configure("./game/config/profile-gc.json", "m-web-admin-api-1", false, mhaya.Cluster) // // 注册调度组件 // app.Register(mhayaCron.New()) // // // 注册检查中心服是否启动组件 // app.Register(checkCenter.New()) // 注册数据配表组件 app.Register(data.New()) // 加载http server组件 app.Register(httpServerComponent(app.Address())) // 注册db组件 app.Register(mhayaMongo.NewComponent()) app.AddActors( &mdb.ActorDB{Name: "m-web-admin-api-1"}, ) // 启动mhaya引擎 app.Startup() } func httpServerComponent(addr string) *mhayaGin.Component { gin.SetMode(gin.DebugMode) // new http server httpServer := mhayaGin.NewHttp("http_server", addr) httpServer.Use(mhayaGin.Cors()) // 注册 controller httpServer.Register(new(router.Controller)) return httpServer }