-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
50 lines (36 loc) · 944 Bytes
/
main.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
47
48
49
50
package main
import (
"flag"
"fmt"
"runtime"
"github.com/astaxie/beego/logs"
"github.com/gin-gonic/gin"
"tdida.me/apis"
"tdida.me/config"
"tdida.me/model"
)
var mode bool
func init() {
flag.BoolVar(&mode, "debug", false, "是否开启开发模式")
logs.Async()
}
func main() {
flag.Parse()
runtime.GOMAXPROCS(runtime.NumCPU())
if !mode {
gin.SetMode(gin.ReleaseMode)
// logs.SetLogger(logs.AdapterMultiFile, `{"filename":"log/tdida.log","separate":["critical", "error", "info"]}`)
}
config.NewConfig(gin.Mode())
model.InitModel()
address := fmt.Sprintf("%s:%s", config.ConfigFile.String("httphost"), config.ConfigFile.String("httpport"))
logs.Info("%s 服务器初始化中... 核数:%d 调试模式:%t", address, runtime.NumCPU(), mode)
router := gin.Default()
router.GET("/", apis.Index)
v1 := router.Group("/v1")
{
v1.GET("/", apis.Index)
}
logs.Info("server成功启动")
router.Run(address)
}