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

pcm.go 1.9 kB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package main
  2. import (
  3. "context"
  4. "flag"
  5. "github.com/zeromicro/go-zero/core/conf"
  6. "github.com/zeromicro/go-zero/core/logx"
  7. "github.com/zeromicro/go-zero/core/service"
  8. "github.com/zeromicro/go-zero/rest"
  9. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/config"
  10. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/cron"
  11. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/handler"
  12. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/mqs"
  13. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
  14. commonConfig "gitlink.org.cn/jcce-pcm/utils/nacos"
  15. )
  16. var configFile = flag.String("f", "api/etc/pcm.yaml", "the config file")
  17. func main() {
  18. flag.Parse()
  19. var bootstrapConfig commonConfig.BootstrapConfig
  20. conf.MustLoad(*configFile, &bootstrapConfig)
  21. //解析业务配置
  22. var c config.Config
  23. nacosConfig := bootstrapConfig.NacosConfig
  24. serviceConfigContent := nacosConfig.InitConfig(func(data string) {
  25. err := conf.LoadFromYamlBytes([]byte(data), &c)
  26. if err != nil {
  27. panic(err)
  28. }
  29. })
  30. err := conf.LoadFromYamlBytes([]byte(serviceConfigContent), &c)
  31. if err != nil {
  32. panic(err)
  33. }
  34. // 注册到nacos
  35. nacosConfig.DiscoveryRest(&c.RestConf)
  36. serviceGroup := service.NewServiceGroup()
  37. defer serviceGroup.Stop()
  38. server := rest.MustNewServer(c.RestConf, rest.WithCors())
  39. ctx := svc.NewServiceContext(c)
  40. // start log component
  41. logx.MustSetup(c.LogConf)
  42. ctx.Cron.Start()
  43. cron.AddCronGroup(ctx)
  44. handler.RegisterHandlers(server, ctx)
  45. serviceGroup.Add(server)
  46. services := []service.Service{
  47. mqs.MustNewQueue("ai", ctx.RedisClient, mqs.NewAiMq(context.Background(), ctx)),
  48. mqs.MustNewQueue("cloud", ctx.RedisClient, mqs.NewCloudMq(context.Background(), ctx)),
  49. mqs.MustNewQueue("hpc", ctx.RedisClient, mqs.NewHpcMq(context.Background(), ctx)),
  50. }
  51. for _, mq := range services {
  52. serviceGroup.Add(mq)
  53. }
  54. logx.Infof("Starting server at %s:%d...\n", c.Host, c.Port)
  55. serviceGroup.Start()
  56. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.