-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
33 lines (27 loc) · 804 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
package main
import (
log "github.com/sirupsen/logrus"
"fmt"
"github.com/Ryan0520/go-mmall/models"
"github.com/Ryan0520/go-mmall/pkg/gredis"
"github.com/Ryan0520/go-mmall/pkg/setting"
"github.com/Ryan0520/go-mmall/routers"
"github.com/fvbock/endless"
"syscall"
)
func main() {
models.Setup()
gredis.SetUp()
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, routers.InitRouter())
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)
}
}