This commit is contained in:
liuchangshun 2023-11-22 09:20:38 +08:00
parent cec47a9608
commit 5a1008b142

View File

@ -14,8 +14,12 @@ import (
"time" "time"
) )
func Run(env string, port string, fun func(), r func(router *gin.Engine)) { func Run(env string, port string, fun func(), r func(router *gin.Engine), zapConfig lxzap.LogConfig) {
_ = lxlog.InitLog() _ = lxlog.InitLog()
err := lxzap.InitLogger(zapConfig)
if err != nil {
panic(err.Error())
}
app := gin.New() app := gin.New()
// 注册zap相关中间件 // 注册zap相关中间件
if env == "dev" { if env == "dev" {
@ -46,7 +50,7 @@ func Run(env string, port string, fun func(), r func(router *gin.Engine)) {
processed <- struct{}{} processed <- struct{}{}
}() }()
// serve // serve
err := srv.ListenAndServe() err = srv.ListenAndServe()
if http.ErrServerClosed != err { if http.ErrServerClosed != err {
log.Fatalf("server not gracefully shutdown, err :%v\n", err) log.Fatalf("server not gracefully shutdown, err :%v\n", err)
} }