-
Notifications
You must be signed in to change notification settings - Fork 78
/
main.go
45 lines (36 loc) · 860 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
package main
import (
. "github.com/wanghongfei/gogate/conf"
"github.com/wanghongfei/gogate/perr"
serv "github.com/wanghongfei/gogate/server"
"os"
)
func main() {
// 初始化
serv.InitGogate("gogate.yml")
// 构造gogate对象
server, err := serv.NewGatewayServer(
App.ServerConfig.Host,
App.ServerConfig.Port,
App.EurekaConfig.RouteFile,
App.ServerConfig.MaxConnection,
)
checkErrorExit(err, true)
Log.Infof("pre filters: %v", server.ExportAllPreFilters())
Log.Infof("post filters: %v", server.ExportAllPostFilters())
// 启动服务器
err = server.Start()
checkErrorExit(err, true)
Log.Info("listener has been closed")
// 等待优雅关闭
err = server.Shutdown()
checkErrorExit(err, false)
}
func checkErrorExit(err error, exit bool) {
if nil != err {
Log.Error(perr.EnvMsg(err))
if exit {
os.Exit(1)
}
}
}