-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
113 lines (99 loc) · 2.98 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package main
import (
"flag"
_ "gateway/docs"
"gateway/lib"
proxy_gprc "gateway/proxy/grpc"
proxy_http "gateway/proxy/http"
"gateway/proxy/manager"
proxy_tcp "gateway/proxy/tcp"
"gateway/router"
"os"
"os/signal"
"syscall"
)
// @title 微服务网关接口文档
// @version 1.0
// @description This is a sample server celler server.
// @termsOfService http://swagger.io/terms/
// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email support@swagger.io
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host localhost:8880
// @BasePath /
// @query.collection.format multi
// @securityDefinitions.basic BasicAuth
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
// @securitydefinitions.oauth2.application OAuth2Application
// @tokenUrl https://example.com/oauth/token
// @scope.write Grants write access
// @scope.admin Grants read and write access to administrative information
// @securitydefinitions.oauth2.implicit OAuth2Implicit
// @authorizationurl https://example.com/oauth/authorize
// @scope.write Grants write access
// @scope.admin Grants read and write access to administrative information
// @securitydefinitions.oauth2.password OAuth2Password
// @tokenUrl https://example.com/oauth/token
// @scope.read Grants read access
// @scope.write Grants write access
// @scope.admin Grants read and write access to administrative information
// @securitydefinitions.oauth2.accessCode OAuth2AccessCode
// @tokenUrl https://example.com/oauth/token
// @authorizationurl https://example.com/oauth/authorize
// @scope.admin Grants read and write access to administrative information
// @x-extension-openapi {"example": "value on a json format"}
func main() {
//lib.InitModule("./conf/dev/", []string{"base", "mysql", "redis"})
//defer lib.Destroy()
conf := flag.String("conf", "dev", "dev or pro")
swag := flag.Bool("swag", false, "true and false")
endpoint := flag.String("endpoint", "dashboard", "dashboard,http,tcp and grpc")
flag.Parse()
if *conf == "pro" {
lib.InitBaseConf("./conf/pro")
lib.InitMysqlConf("./conf/pro")
lib.InitRedisConf("./conf/pro")
lib.InitProxyConf("./conf/pro")
lib.InitRedis()
lib.InitDBPool()
} else {
lib.InitBaseConf("./conf/dev")
lib.InitMysqlConf("./conf/dev")
lib.InitRedisConf("./conf/dev")
lib.InitProxyConf("./conf/dev")
lib.InitRedis()
lib.InitDBPool()
}
//db,_:=lib.GetDefaultDB()
//db.Logger.LogMode(logger.Info)
switch *endpoint {
case "dashboard":
{
router.HttpServerRun(*swag)
defer router.HttpServerStop()
}
case "http":
{
manager.InitManager()
proxy_http.HttpServerRun()
defer proxy_http.HttpServerStop()
}
case "tcp":
{
proxy_tcp.TcpServerRun()
defer proxy_tcp.TcpServerStop()
}
case "grpc":
{
proxy_gprc.GrpcServerRun()
defer proxy_gprc.GrpcServerStop()
}
}
quit := make(chan os.Signal)
signal.Notify(quit, syscall.SIGKILL, syscall.SIGQUIT, syscall.SIGINT, syscall.SIGTERM)
<-quit
}