You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
2.5 KiB
121 lines
2.5 KiB
package main
|
|
|
|
import (
|
|
Middleware "dsDataex/MiddleWare"
|
|
"dsDataex/MyService/Auth/AuthGrpc"
|
|
"dsDataex/MyService/Auth/AuthGrpc/AuthGrpcProto"
|
|
"dsDataex/Router"
|
|
"dsDataex/Utils"
|
|
"dsDataex/Utils/CacheUtil"
|
|
"dsDataex/Utils/ConfigUtil"
|
|
"dsDataex/Utils/ES7Util"
|
|
"dsDataex/Utils/KafkaUtil"
|
|
_ "dsDataex/docs"
|
|
"fmt"
|
|
"github.com/gin-gonic/gin"
|
|
"golang.org/x/sync/errgroup"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/reflection"
|
|
"log"
|
|
"net"
|
|
)
|
|
|
|
var (
|
|
r *gin.Engine
|
|
|
|
s *grpc.Server
|
|
|
|
g errgroup.Group
|
|
)
|
|
|
|
func GrpcServerInit() {
|
|
|
|
s = grpc.NewServer()
|
|
|
|
AuthGrpcProto.RegisterAuthGrpcServiceServer(s, &AuthGrpc.Rpc{})
|
|
|
|
reflection.Register(s)
|
|
}
|
|
|
|
func GinServerInit() {
|
|
|
|
gin.SetMode(gin.DebugMode)
|
|
|
|
r = gin.Default()
|
|
|
|
//启用日志中间件
|
|
r.Use(Middleware.LoggerToKafka())
|
|
|
|
r.Use(Utils.Cors())
|
|
|
|
r.GET("/", func(c *gin.Context) {
|
|
c.JSON(200, "dsDataEX GO !!!")
|
|
})
|
|
|
|
//add by wangshuai 2020-07-14
|
|
r.Static("/docs", "./docs")
|
|
//add by wangshuai 2020-11-03
|
|
r.Static("/dsDataex", "./html")
|
|
//r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
|
|
|
//主路由
|
|
Router.GinRouter(r)
|
|
|
|
//rgroup := r.Group("v1")
|
|
|
|
|
|
|
|
//Mock Service for Swagger ,path 前面增加 mock/
|
|
//SwagMock.Init(r)
|
|
}
|
|
|
|
// @title DataEX
|
|
// @version 1.0
|
|
// @description DataEX Service using GO!!! create by zhangjun 2020-06-03
|
|
// @termsOfService http://swagger.io/terms/
|
|
// @contact.name API Support
|
|
// @contact.url http://www.swagger.io/support
|
|
// @contact.email 53766543@qq.com
|
|
// @license.name Apache 2.0
|
|
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
|
// @host 127.0.0.1:9009
|
|
// @BasePath /
|
|
// @query.collection.format multi
|
|
// @securityDefinitions.basic BasicAuth
|
|
func main() {
|
|
|
|
fmt.Println("DsDataEX GO ! GO !! GO !!!")
|
|
|
|
fmt.Println("ES Server :" + ES7Util.ServerVersion)
|
|
//fmt.Println("ES Server :" + ES7SqlUtil.ServerVersion)
|
|
fmt.Println("Kafka Server :" + KafkaUtil.KafkaBroker )
|
|
|
|
//KafkaUtil.CreateTopic2("log_test")
|
|
//var token=MD5Util.MD5V1("TEST_007" + "20200707" + "DSDataex_Token_7ee1f0f76243449f8d75f40fdcc2b93d")
|
|
//fmt.Println("AccessToken : "+token)
|
|
|
|
CacheUtil.OrgtreeCacheInit()
|
|
|
|
GinServerInit()
|
|
|
|
g.Go(func() error {
|
|
fmt.Printf("dsDataEX Gin服务启动成功,服务地址: http://127.0.0.1:%s/docs \n", ConfigUtil.ProjectPort)
|
|
|
|
return r.Run(":" + ConfigUtil.ProjectPort)
|
|
})
|
|
|
|
GrpcServerInit()
|
|
|
|
g.Go(func() error {
|
|
lis, _ := net.Listen("tcp", ":"+ConfigUtil.ProjectGrpc)
|
|
|
|
fmt.Printf("dsDataEX GRPC服务发布成功,服务地址: %s\n", ConfigUtil.ProjectGrpc)
|
|
|
|
return s.Serve(lis)
|
|
})
|
|
|
|
if err := g.Wait(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|