-
Notifications
You must be signed in to change notification settings - Fork 1
/
goPush.go
46 lines (41 loc) · 1.05 KB
/
goPush.go
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
37
38
39
40
41
42
43
44
45
46
package main
import (
"github.com/gin-contrib/pprof"
"github.com/gin-gonic/gin"
"goPush/controllers"
"goPush/lib/config"
"goPush/lib/log"
"goPush/lib/push"
)
func main() {
//初始化配置文件
config.Instance = new(config.Config)
config.Instance.InitConfig("conf/app.ini")
runMode := config.Instance.Get("default", "runMode")
port := config.Instance.Get("default", "port")
//初始化logger
log.Instance = new(log.Logger)
log.Instance.InitLogger("logs")
if runMode == "dev" {
gin.SetMode(gin.DebugMode)
log.Instance.SetLevel(log.DEBUG)
log.Instance.SetConsole(true)
} else {
gin.SetMode(gin.ReleaseMode)
log.Instance.SetLevel(log.INFO)
log.Instance.SetConsole(false)
}
//初始化ios client
push.IosInstance = new(push.Ios)
push.IosInstance.InitClient()
//初始化路由
r := gin.Default()
//debug cpu 内存等
pprof.Register(r, &pprof.Options{
RoutePrefix: "debug/pprof",
})
pushController := new(controllers.PushController)
pushGroup := r.Group("/api")
pushGroup.POST("/push", pushController.Push)
r.Run(":" + port)
}