2017-09-11 02:24:18 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"flag"
|
|
|
|
|
|
|
|
"git.loafle.net/commons_go/config"
|
|
|
|
"git.loafle.net/commons_go/logging"
|
2017-09-19 08:38:59 +00:00
|
|
|
"git.loafle.net/overflow/overflow_gateway_probe/conf"
|
2017-09-11 02:24:18 +00:00
|
|
|
"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()
|
|
|
|
|
2017-09-19 08:38:59 +00:00
|
|
|
config.SetConfigPath(*configPath)
|
|
|
|
if err := config.Load(&conf.Config, "config.json"); nil != err {
|
|
|
|
panic(err)
|
|
|
|
}
|
2017-09-11 02:24:18 +00:00
|
|
|
|
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())
|
|
|
|
|
2017-09-19 08:38:59 +00:00
|
|
|
s.HandleSocket(conf.Config.Handlers["probe"].Entry, psh)
|
|
|
|
s.HandleSocket(conf.Config.Handlers["auth"].Entry, ash)
|
2017-09-11 02:24:18 +00:00
|
|
|
|
2017-09-19 08:38:59 +00:00
|
|
|
s.ListenAndServe(conf.Config.Server.Addr)
|
2017-09-11 02:24:18 +00:00
|
|
|
}
|