-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
72 lines (63 loc) · 1.67 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
package main
import (
"flag"
"github.com/Kirov7/FayGateway/dao"
"github.com/Kirov7/FayGateway/grpc_proxy_router"
"github.com/Kirov7/FayGateway/http_proxy_router"
"github.com/Kirov7/FayGateway/router"
"github.com/Kirov7/FayGateway/tcp_proxy_router"
"github.com/Kirov7/go-config/lib"
"os"
"os/signal"
"syscall"
)
// endpoint dashboard后台管理 server代理服务器
// conf ./conf/prod/ 对应配置文件夹
var (
endpoint = flag.String("endpoint", "server", "input endpoint dashboard or server")
config = flag.String("conf", "./conf/dev/", "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, []string{"base", "mysql", "redis"})
defer lib.Destroy()
router.HttpServerRun()
quit := make(chan os.Signal)
signal.Notify(quit, syscall.SIGKILL, syscall.SIGQUIT, syscall.SIGINT, syscall.SIGTERM)
<-quit
router.HttpServerStop()
} else {
lib.InitModule(*config, []string{"base", "mysql", "redis"})
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.SIGKILL, syscall.SIGQUIT, syscall.SIGINT, syscall.SIGTERM)
<-quit
tcp_proxy_router.TcpServerStop()
grpc_proxy_router.GrpcServerStop()
http_proxy_router.HttpsServerStop()
http_proxy_router.HttpServerStop()
}
}