-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (42 loc) · 1.22 KB
/
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
51
52
53
package main
import (
"fmt"
"log"
"syscall"
"github.com/fvbock/endless"
"github.com/jweboy/api-server/model"
"github.com/jweboy/api-server/pkg/setting"
"github.com/jweboy/api-server/router"
)
// 118.24.155.105
// @host 118.24.155.105:4000
// @BasePath /api/v1
func main() {
// 初始化项目基础配置
setting.Setup()
// 初始化数据库连接
model.DB.Init()
defer model.DB.Close()
endless.DefaultReadTimeOut = setting.ServerSetting.ReadTimeout
endless.DefaultWriteTimeOut = setting.ServerSetting.WriteTimeout
endless.DefaultMaxHeaderBytes = 1 << 20
endPoint := fmt.Sprintf(":%d", setting.ServerSetting.HTTPPort)
server := endless.NewServer(endPoint, router.Load())
server.BeforeBegin = func(add string) {
log.Printf("Actual pid is %d", syscall.Getpid())
}
err := server.ListenAndServe()
if err != nil {
log.Printf("Server err: %v", err)
}
// 初始化gin
// runmode := cfg.Section("").Key("app_mode").String()
// gin.SetMode(runmode)
// g := gin.New()
// // middlewares := []gin.HandlerFunc{}
// server := cfg.Section("server")
// port := server.Key("port").String()
// http.ListenAndServe(port, g).Error()
// fmt.Println()
// fmt.Println("App Mode:", cfg.Section("").Key("app_mode").String())
}