64 lines
1.9 KiB
Go
64 lines
1.9 KiB
Go
/*
|
|
|
|
Copyright (c) [2023] [pcm]
|
|
[pcm-coordinator] is licensed under Mulan PSL v2.
|
|
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
You may obtain a copy of Mulan PSL v2 at:
|
|
http://license.coscl.org.cn/MulanPSL2
|
|
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
See the Mulan PSL v2 for more details.
|
|
|
|
*/
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"github.com/zeromicro/go-zero/core/conf"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"github.com/zeromicro/go-zero/core/service"
|
|
"github.com/zeromicro/go-zero/rest"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/config"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/cron"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/handler"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/mqs"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
|
)
|
|
|
|
var configFile = flag.String("f", "api/etc/pcm.yaml", "the config file")
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
|
|
var c config.Config
|
|
conf.MustLoad(*configFile, &c)
|
|
|
|
serviceGroup := service.NewServiceGroup()
|
|
defer serviceGroup.Stop()
|
|
|
|
server := rest.MustNewServer(c.RestConf, rest.WithCors())
|
|
|
|
ctx := svc.NewServiceContext(c)
|
|
// start log component
|
|
logx.MustSetup(c.LogConf)
|
|
ctx.Cron.Start()
|
|
cron.AddCronGroup(ctx)
|
|
handler.RegisterHandlers(server, ctx)
|
|
|
|
serviceGroup.Add(server)
|
|
services := []service.Service{
|
|
//mqs.MustNewQueue("ai", mqs.NewAiMq(context.Background(), ctx)),
|
|
mqs.MustNewQueue("cloud", mqs.NewCloudMq(context.Background(), ctx)),
|
|
//mqs.MustNewQueue("hpc", mqs.NewHpcMq(context.Background(), ctx)),
|
|
}
|
|
for _, mq := range services {
|
|
serviceGroup.Add(mq)
|
|
}
|
|
logx.Infof("Starting server at %s:%d...\n", c.Host, c.Port)
|
|
serviceGroup.Start()
|
|
|
|
}
|