加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 2.20 KB
一键复制 编辑 原始数据 按行查看 历史
package main
import (
"runtime"
"github.com/baetyl/baetyl-go/v2/context"
"github.com/baetyl/baetyl-go/v2/log"
_ "github.com/go-sql-driver/mysql"
"github.com/baetyl/baetyl-cloud/v2/api"
"github.com/baetyl/baetyl-cloud/v2/common"
"github.com/baetyl/baetyl-cloud/v2/config"
"github.com/baetyl/baetyl-cloud/v2/plugin"
_ "github.com/baetyl/baetyl-cloud/v2/plugin/awss3"
_ "github.com/baetyl/baetyl-cloud/v2/plugin/database"
_ "github.com/baetyl/baetyl-cloud/v2/plugin/decryption"
_ "github.com/baetyl/baetyl-cloud/v2/plugin/default/auth"
_ "github.com/baetyl/baetyl-cloud/v2/plugin/default/csrf"
_ "github.com/baetyl/baetyl-cloud/v2/plugin/default/license"
_ "github.com/baetyl/baetyl-cloud/v2/plugin/default/lock"
_ "github.com/baetyl/baetyl-cloud/v2/plugin/default/pki"
_ "github.com/baetyl/baetyl-cloud/v2/plugin/default/sign"
_ "github.com/baetyl/baetyl-cloud/v2/plugin/default/task"
_ "github.com/baetyl/baetyl-cloud/v2/plugin/default/transaction"
_ "github.com/baetyl/baetyl-cloud/v2/plugin/kube"
_ "github.com/baetyl/baetyl-cloud/v2/plugin/link/httplink"
_ "github.com/baetyl/baetyl-cloud/v2/plugin/sign"
"github.com/baetyl/baetyl-cloud/v2/server"
)
func main() {
defer plugin.ClosePlugins()
runtime.GOMAXPROCS(runtime.NumCPU())
context.Run(func(ctx context.Context) error {
var cfg config.CloudConfig
err := ctx.LoadCustomConfig(&cfg)
if err != nil {
return err
}
ctx.Log().Debug("cloud config", log.Any("cfg", cfg))
common.SetConfFile(ctx.ConfFile())
a, err := api.NewAPI(&cfg)
if err != nil {
return err
}
sa, err := api.NewSyncAPI(&cfg)
if err != nil {
return err
}
ia, err := api.NewInitAPI(&cfg)
if err != nil {
return err
}
s, err := server.NewAdminServer(&cfg)
if err != nil {
return err
}
s.SetAPI(a)
s.InitRoute()
go s.Run()
defer s.Close()
ctx.Log().Info("admin server starting")
ss, err := server.NewSyncServer(&cfg)
if err != nil {
return err
}
ss.SetSyncAPI(sa)
ss.InitMsgRouter()
ss.Run()
defer ss.Close()
as, err := server.NewInitServer(&cfg)
if err != nil {
return err
}
as.SetAPI(ia)
as.InitRoute()
go as.Run()
defer as.Close()
ctx.Log().Info("init server starting")
ctx.Wait()
return nil
})
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化