59 lines
1.1 KiB
Go
59 lines
1.1 KiB
Go
package main
|
||
|
||
import (
|
||
"flag"
|
||
"fmt"
|
||
"go_dreamfactory/modules/gateway"
|
||
"go_dreamfactory/services"
|
||
"go_dreamfactory/sys/db"
|
||
|
||
"go_dreamfactory/lego"
|
||
"go_dreamfactory/lego/base/rpcx"
|
||
"go_dreamfactory/lego/core"
|
||
"go_dreamfactory/lego/sys/log"
|
||
)
|
||
|
||
/*
|
||
服务类型:gateway
|
||
服务描述:网关服务,提供客户端连接的服务,管理用户的socket对象以及用户消息的分发,只包含gateway业务模块
|
||
*/
|
||
var (
|
||
conf = flag.String("conf", "./conf/gateway_1.yaml", "获取需要启动的服务配置文件") //启动服务的Id
|
||
)
|
||
|
||
func main() {
|
||
flag.Parse()
|
||
s := NewService(
|
||
rpcx.SetConfPath(*conf),
|
||
rpcx.SetVersion("1.0.0.0"),
|
||
)
|
||
s.OnInstallComp( //装备组件
|
||
)
|
||
|
||
lego.Run(s, //运行模块
|
||
gateway.NewModule(),
|
||
)
|
||
|
||
}
|
||
|
||
func NewService(ops ...rpcx.Option) core.IService {
|
||
s := new(Service)
|
||
s.Configure(ops...)
|
||
return s
|
||
}
|
||
|
||
type Service struct {
|
||
services.ServiceBase
|
||
}
|
||
|
||
func (this *Service) InitSys() {
|
||
this.ServiceBase.InitSys()
|
||
|
||
//存储系统
|
||
if err := db.OnInit(this.GetSettings().Sys["db"]); err != nil {
|
||
panic(fmt.Sprintf("init sys.db err: %s", err.Error()))
|
||
} else {
|
||
log.Infof("init sys.db success!")
|
||
}
|
||
}
|