-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
87 lines (69 loc) · 1.63 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package main
import (
"flag"
"github.com/go1234.cn/gin_scaffold/dao"
"github.com/go1234.cn/gin_scaffold/golang_common/lib"
"github.com/go1234.cn/gin_scaffold/grpc_proxy_router"
"github.com/go1234.cn/gin_scaffold/http_proxy_router"
"github.com/go1234.cn/gin_scaffold/tcp_proxy_router"
"os"
"os/signal"
"syscall"
)
var (
//dashaboard后台管理 server代理服务器
endpoint = flag.String("endpoint", "", "input endpoint dashaboard or server")
//配置文件路径
config = flag.String("config", "./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("./conf/dev/")
defer lib.Destroy()
//start
router.HttpServerRun()
quit := make(chan os.Signal)
signal.Notify(quit, syscall.SIGKILL, syscall.SIGQUIT, syscall.SIGINT, syscall.SIGTERM)
<-quit
//stop
router.HttpServerStop()*/
} else {
lib.InitModule(*config)
defer lib.Destroy()
//将服务加载到内存中
dao.ServiceManagerHandler.LoadOnce()
//start 80
go func() {
http_proxy_router.HttpServerRun()
}()
//start 443
go func() {
http_proxy_router.HttpsServerRun()
}()
//tcp服务
go func() {
tcp_proxy_router.TcpServerRun()
}()
//grpc代理
go func() {
grpc_proxy_router.GrpcServerRun()
}()
quit := make(chan os.Signal)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit
//stop
http_proxy_router.HttpServerStop()
http_proxy_router.HttpsServerStop()
grpc_proxy_router.GrpcServerStop()
tcp_proxy_router.TcpServerStop()
}
}