refactor: reorganize modules and add Linux build tooling
This commit is contained in:
53
module/base/logs/cmd/main/main.go
Normal file
53
module/base/logs/cmd/main/main.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"bsm/full/module/base/logs/internal/config"
|
||||
"bsm/full/module/base/logs/internal/impl"
|
||||
"bsm/full/module/base/logs/internal/routers"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/env"
|
||||
"git.apinb.com/bsm-sdk/core/infra"
|
||||
"git.apinb.com/bsm-sdk/core/vars"
|
||||
)
|
||||
|
||||
var (
|
||||
ServiceKey = "logs"
|
||||
)
|
||||
|
||||
func Run() {
|
||||
config.New(ServiceKey)
|
||||
impl.NewImpl()
|
||||
|
||||
// 初始化Gin引擎
|
||||
app := gin.Default()
|
||||
|
||||
// 设置gin模式
|
||||
if env.Runtime.Mode == vars.RUN_MODE_PROD {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
} else {
|
||||
gin.SetMode(gin.DebugMode)
|
||||
}
|
||||
|
||||
// use middleware
|
||||
app.Use(gin.Recovery())
|
||||
|
||||
// register health check
|
||||
app.HEAD("/", infra.Health)
|
||||
|
||||
// register routers
|
||||
routers.Register(ServiceKey, app)
|
||||
|
||||
// start
|
||||
err := app.Run(fmt.Sprintf(":%s", config.Spec.Port))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
Run()
|
||||
}
|
||||
Reference in New Issue
Block a user