-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
73 lines (63 loc) · 1.56 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"flag"
"github.com/e421083458/go_gateway/dao"
"github.com/e421083458/go_gateway/golang_common/lib"
"github.com/e421083458/go_gateway/grpc_proxy_router"
"github.com/e421083458/go_gateway/http_proxy_router"
"github.com/e421083458/go_gateway/router"
"github.com/e421083458/go_gateway/tcp_proxy_router"
"os"
"os/signal"
"syscall"
)
//endpoint dashboard后台管理 server代理服务器
//config ./conf/prod/ 对应配置文件夹
var (
endpoint = flag.String("endpoint", "", "input endpoint dashboard or server")
config = flag.String("config", "", "input config file like ./conf/dev/")
)
func main() {
flag.Parse()
if *endpoint == "" {
flag.Usage()
os.Exit(1)
}
if *config == "" {
flag.Usage()
os.Exit(1)
}
if *endpoint == "dashboard" {
lib.InitModule(*config)
defer lib.Destroy()
router.HttpServerRun()
quit := make(chan os.Signal)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit
router.HttpServerStop()
} else {
lib.InitModule(*config)
defer lib.Destroy()
dao.ServiceManagerHandler.LoadOnce()
dao.AppManagerHandler.LoadOnce()
go func() {
http_proxy_router.HttpServerRun()
}()
go func() {
http_proxy_router.HttpsServerRun()
}()
go func() {
tcp_proxy_router.TcpServerRun()
}()
go func() {
grpc_proxy_router.GrpcServerRun()
}()
quit := make(chan os.Signal)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit
tcp_proxy_router.TcpServerStop()
grpc_proxy_router.GrpcServerStop()
http_proxy_router.HttpServerStop()
http_proxy_router.HttpsServerStop()
}
}