60 lines
1.2 KiB
Go
60 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"go_dreamfactory/modules/version"
|
|
"go_dreamfactory/services"
|
|
"go_dreamfactory/sys/db"
|
|
|
|
"go_dreamfactory/lego"
|
|
"go_dreamfactory/lego/base/rpcx"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/sys/log"
|
|
)
|
|
|
|
/*
|
|
服务类型:mainte
|
|
服务描述:数据库维护以及GM后台接口 服务
|
|
*/
|
|
var (
|
|
conf = flag.String("conf", "./conf/version.yaml", "获取需要启动的服务配置文件") //启动服务的Id
|
|
)
|
|
|
|
/*服务启动的入口函数*/
|
|
func main() {
|
|
flag.Parse()
|
|
s := NewService(
|
|
rpcx.SetConfPath(*conf),
|
|
rpcx.SetVersion("1.0.0.0"),
|
|
)
|
|
s.OnInstallComp( //装备组件
|
|
//services.NewGateRouteComp(), //此服务需要接受用户的消息 需要装备网关组件
|
|
)
|
|
lego.Run(s, //运行模块
|
|
version.NewModule(),
|
|
)
|
|
}
|
|
|
|
func NewService(ops ...rpcx.Option) core.IService {
|
|
s := new(Service)
|
|
s.Configure(ops...)
|
|
return s
|
|
}
|
|
|
|
// worker 的服务对象定义
|
|
type Service struct {
|
|
services.ServiceBase
|
|
}
|
|
|
|
// 初始化worker需要的一些系统工具
|
|
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!")
|
|
}
|
|
}
|