pcm-hpc/main.go

89 lines
2.6 KiB
Go

package main
import (
"github.com/robfig/cron"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-hpc/core"
"gitlink.org.cn/JointCloud/pcm-hpc/global"
)
//
//func init() {
// var resp types.ClusterResp
// httpClient := resty.New().R()
// params := map[string]string{
// "type": "2",
// "pageNum": "1",
// "pageSize": "10",
// "adapterId": strconv.FormatInt(global.System.AdapterId, 10),
// }
//
// _, err := httpClient.SetHeader("Content-Type", "application/json").
// SetQueryParams(params).
// SetResult(&resp).
// Get(global.System.CoreServerUrl + "/pcm/v1/core/clusterList")
// if err != nil {
// log.Fatal(err)
// }
// for _, cluster := range resp.Data.List {
// switch cluster.Label {
// case "slurm":
// slurmClient, _ := slurm.NewClient(slurm.ClientOptions{
// AdapterId: cluster.AdapterId,
// ClusterId: cluster.Id,
// RestUserName: cluster.Username,
// CmdUserName: cluster.Username,
// Password: cluster.Password,
// Token: cluster.Token,
// URL: cluster.Server,
// AdaptMode: cluster.AuthType,
// ClientVersion: cluster.Version,
// })
// cronPCM.SlurmClients = append(cronPCM.SlurmClients, slurmClient)
// case "ac":
//
// acClient, _ := ac.NewClient(ac.ClientOptions{
// AdapterId: cluster.AdapterId,
// ClusterId: cluster.Id,
// ClusterUrl: confHpc.ConfigHpc.ACConfig.ClusterUrl,
// TokenUrl: confHpc.ConfigHpc.ACConfig.TokenUrl,
// StateUrl: confHpc.ConfigHpc.ACConfig.StateUrl,
// User: cluster.Username,
// Password: cluster.Password,
// OrgId: cluster.OwnerId,
// EndPoint: confHpc.ConfigHpc.ACConfig.AcBaseUrl,
// ClusterIdAC: cluster.ProjectId,
// BaseEndpoint: confHpc.ConfigHpc.ACConfig.AcBaseUrl})
// cronPCM.AcClients = append(cronPCM.AcClients, acClient)
//
// case "paratera":
// parateraClient, _ := paratera.NewClient(paratera.ClientOptions{
// AdapterId: cluster.AdapterId,
// ClusterId: cluster.Id,
// Url: cluster.Server,
// TokenType: "TOKEN",
// ThirdParty: cluster.ProjectId,
// Phone: cluster.Username,
// Password: cluster.Password})
// cronPCM.ParateraClients = append(cronPCM.ParateraClients, parateraClient)
// }
// }
//}
func main() {
global.PCM_VP = core.Viper()
c := cron.New()
// pull task list from coordinator
c.AddFunc("*/30 * * * * ?", func() {
//cronPCM.PullTaskInfo()
})
c.AddFunc("*/60 * * * * ?", func() {
//cronPCM.updateTaskStatus()
})
// 启动定时任务
c.Start()
core.RunServer()
logx.Infof("Server started")
}