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 2.4 kB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. Copyright (c) [2023] [pcm]
  3. [pcm-coordinator] is licensed under Mulan PSL v2.
  4. You can use this software according to the terms and conditions of the Mulan PSL v2.
  5. You may obtain a copy of Mulan PSL v2 at:
  6. http://license.coscl.org.cn/MulanPSL2
  7. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  8. EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  9. MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  10. See the Mulan PSL v2 for more details.
  11. */
  12. package main
  13. import (
  14. "context"
  15. "flag"
  16. "github.com/zeromicro/go-zero/core/conf"
  17. "github.com/zeromicro/go-zero/core/logx"
  18. "github.com/zeromicro/go-zero/core/service"
  19. "github.com/zeromicro/go-zero/rest"
  20. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/config"
  21. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/cron"
  22. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/handler"
  23. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/mqs"
  24. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
  25. commonConfig "gitlink.org.cn/jcce-pcm/utils/nacos"
  26. )
  27. var configFile = flag.String("f", "api/etc/pcm.yaml", "the config file")
  28. func main() {
  29. flag.Parse()
  30. var bootstrapConfig commonConfig.BootstrapConfig
  31. conf.MustLoad(*configFile, &bootstrapConfig)
  32. //解析业务配置
  33. var c config.Config
  34. nacosConfig := bootstrapConfig.NacosConfig
  35. serviceConfigContent := nacosConfig.InitConfig(func(data string) {
  36. err := conf.LoadFromYamlBytes([]byte(data), &c)
  37. if err != nil {
  38. panic(err)
  39. }
  40. })
  41. err := conf.LoadFromYamlBytes([]byte(serviceConfigContent), &c)
  42. if err != nil {
  43. panic(err)
  44. }
  45. // 注册到nacos
  46. nacosConfig.DiscoveryRest(&c.RestConf)
  47. serviceGroup := service.NewServiceGroup()
  48. defer serviceGroup.Stop()
  49. server := rest.MustNewServer(c.RestConf, rest.WithCors())
  50. ctx := svc.NewServiceContext(c)
  51. // start log component
  52. logx.MustSetup(c.LogConf)
  53. ctx.Cron.Start()
  54. cron.AddCronGroup(ctx)
  55. handler.RegisterHandlers(server, ctx)
  56. serviceGroup.Add(server)
  57. services := []service.Service{
  58. mqs.MustNewQueue("ai", ctx.RedisClient, mqs.NewAiMq(context.Background(), ctx)),
  59. mqs.MustNewQueue("cloud", ctx.RedisClient, mqs.NewCloudMq(context.Background(), ctx)),
  60. mqs.MustNewQueue("hpc", ctx.RedisClient, mqs.NewHpcMq(context.Background(), ctx)),
  61. }
  62. for _, mq := range services {
  63. serviceGroup.Add(mq)
  64. }
  65. logx.Infof("Starting server at %s:%d...\n", c.Host, c.Port)
  66. serviceGroup.Start()
  67. }

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.