-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
36 lines (30 loc) · 905 Bytes
/
main.go
File metadata and controls
36 lines (30 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"fmt"
"github.com/chxfantasy/go_bootstrap/domain/health"
"github.com/chxfantasy/go_bootstrap/middleware"
config "github.com/chxfantasy/go_bootstrap/conf"
"github.com/chxfantasy/go_bootstrap/conf/scheduler"
"github.com/chxfantasy/go_bootstrap/utils"
"github.com/gin-gonic/gin"
)
func main() {
fmt.Println("hello go bootstrap")
config.Gin.Use(middleware.Boss(config.AppConf.Server.Name, config.TraceLogger))
initRouter(config.Gin)
go scheduler.InitScheduler()
serverPort := config.AppConf.Server.Port
if serverPort <= 0 {
serverPort = 7001
}
addr := fmt.Sprintf("%s:%d", "0.0.0.0", serverPort)
config.BizLogger.Info("listen address:", "addr", addr)
err := utils.ListenAndServe(addr, config.Gin)
if err != nil {
config.BizLogger.Errorf("start listener err: %v, addr: %v", err, addr)
return
}
}
func initRouter(app *gin.Engine) {
health.InitRouter(app)
}