70 lines
2.2 KiB
Go
70 lines
2.2 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"github.com/zeromicro/go-zero/core/conf"
|
|
"github.com/zeromicro/go-zero/core/service"
|
|
"github.com/zeromicro/go-zero/zrpc"
|
|
"gitlink.org.cn/JointCloud/pcm-openstack/internal/common"
|
|
"gitlink.org.cn/JointCloud/pcm-openstack/internal/pkg/cron"
|
|
"gitlink.org.cn/JointCloud/pcm-openstack/internal/server"
|
|
"gitlink.org.cn/JointCloud/pcm-openstack/internal/svc"
|
|
"gitlink.org.cn/JointCloud/pcm-openstack/openstack"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/reflection"
|
|
)
|
|
|
|
// var configFile = flag.String("f", "etc/pcmopenstack.yaml", "the config file")
|
|
|
|
func main() {
|
|
flag.StringVar(&common.FileName, "f", "etc/pcmopenstack.yaml", "the config file")
|
|
flag.Parse()
|
|
conf.MustLoad(common.FileName, &common.C)
|
|
ctx := svc.NewServiceContext(common.C)
|
|
//解析业务配置
|
|
s := zrpc.MustNewServer(common.C.RpcServerConf, func(grpcServer *grpc.Server) {
|
|
openstack.RegisterOpenstackServer(grpcServer, server.NewOpenstackServer(ctx))
|
|
if common.C.Mode == service.DevMode || common.C.Mode == service.TestMode {
|
|
reflection.Register(grpcServer)
|
|
}
|
|
})
|
|
defer s.Stop()
|
|
// 启动并添加定时任务
|
|
ctx.Cron.Start()
|
|
cron.AddCronGroup(ctx)
|
|
// 推送p端静态信息
|
|
// PushParticipantInfo(ctx.Config, ctx.ParticipantRpc)
|
|
// logx.Infof("Starting rpc server at %s...\n", common.C.ListenOn)
|
|
s.Start()
|
|
|
|
}
|
|
|
|
/*// PushParticipantInfo 推送p端静态信息
|
|
func PushParticipantInfo(config config.Config, participantService participantservice.ParticipantService) {
|
|
participantId, err := utils.GetParticipantId(*&common.FileName)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
// 从配置文件中读取participant标签信息
|
|
var labels []*pcmCore.ParticipantLabel
|
|
for k, v := range config.Participant.Labels {
|
|
labels = append(labels, &pcmCore.ParticipantLabel{
|
|
Key: k,
|
|
Value: v,
|
|
})
|
|
}
|
|
req := participantservice.ParticipantPhyReq{}
|
|
utils.Convert(config.Participant, &req)
|
|
req.ParticipantId = participantId
|
|
req.LabelInfo = labels
|
|
//
|
|
resp, err := participantService.RegisterParticipant(context.Background(), &req)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
// 更新本地配置文件ParticipantId
|
|
utils.UpdateParticipantId(*&common.FileName, strconv.FormatInt(resp.ParticipantId, 10))
|
|
}*/
|