2017-09-11 02:24:18 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"flag"
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"git.loafle.net/commons_go/config"
|
|
|
|
"git.loafle.net/commons_go/logging"
|
|
|
|
"git.loafle.net/overflow/overflow_gateway_probe/grpc"
|
|
|
|
"git.loafle.net/overflow/overflow_gateway_probe/handler"
|
|
|
|
"git.loafle.net/overflow/overflow_gateway_probe/redis"
|
|
|
|
"git.loafle.net/overflow/overflow_gateway_probe/server"
|
|
|
|
"git.loafle.net/overflow/overflow_gateway_probe/subscribe"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
configPath := flag.String("config", ".", "The path of config file")
|
|
|
|
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
loadConfig(*configPath)
|
|
|
|
|
2017-09-11 04:42:52 +00:00
|
|
|
ctx := context.Background()
|
|
|
|
|
|
|
|
defer logging.Logger.Sync()
|
2017-09-11 02:24:18 +00:00
|
|
|
|
|
|
|
s := server.NewServer(ctx)
|
|
|
|
rp := redis.NewPool(ctx)
|
|
|
|
grpc.InitializePool(ctx)
|
|
|
|
|
|
|
|
psh := handler.NewProbeSocketHandler(ctx)
|
|
|
|
ash := handler.NewAuthSocketHandler(ctx)
|
|
|
|
|
|
|
|
subscribe.Subscribe(ctx, rp.Get())
|
|
|
|
|
|
|
|
s.HandleSocket(config.GetString("handlers.probe.entry"), psh)
|
|
|
|
s.HandleSocket(config.GetString("handlers.auth.entry"), ash)
|
|
|
|
|
|
|
|
s.ListenAndServe(config.GetString("server.addr"))
|
|
|
|
}
|
|
|
|
|
|
|
|
func loadConfig(path string) {
|
|
|
|
config.SetConfigName("config")
|
|
|
|
config.AddConfigPath(path)
|
|
|
|
err := config.ReadInConfig()
|
|
|
|
if nil != err {
|
|
|
|
log.Fatalf("config error: %v", err)
|
|
|
|
}
|
|
|
|
}
|