deprecated_overflow_gateway.../main.go

43 lines
988 B
Go
Raw Permalink Normal View History

2017-08-24 11:51:02 +00:00
package main
import (
2017-08-29 08:58:37 +00:00
"context"
2017-09-08 04:53:16 +00:00
"flag"
2017-08-25 10:41:43 +00:00
2017-08-30 10:26:32 +00:00
"git.loafle.net/commons_go/config"
2017-08-30 06:50:56 +00:00
"git.loafle.net/commons_go/logging"
2017-09-19 08:28:21 +00:00
"git.loafle.net/overflow/overflow_gateway_web/conf"
2017-09-01 06:42:23 +00:00
"git.loafle.net/overflow/overflow_gateway_web/grpc"
"git.loafle.net/overflow/overflow_gateway_web/handler"
"git.loafle.net/overflow/overflow_gateway_web/redis"
"git.loafle.net/overflow/overflow_gateway_web/server"
"git.loafle.net/overflow/overflow_gateway_web/subscribe"
2017-08-24 11:51:02 +00:00
)
func main() {
2017-09-19 08:28:21 +00:00
configPath := flag.String("config", "./", "The path of config file")
2017-09-08 04:53:16 +00:00
flag.Parse()
2017-09-19 08:28:21 +00:00
config.SetConfigPath(*configPath)
if err := config.Load(&conf.Config, "config.json"); nil != err {
panic(err)
}
2017-09-11 03:58:15 +00:00
ctx := context.Background()
2017-08-30 10:26:32 +00:00
2017-09-11 03:58:15 +00:00
defer logging.Logger.Sync()
2017-08-30 06:50:56 +00:00
2017-09-01 06:42:23 +00:00
s := server.NewServer(ctx)
rp := redis.NewPool(ctx)
2017-09-05 07:48:19 +00:00
grpc.InitializePool(ctx)
2017-08-28 09:41:41 +00:00
2017-09-05 07:48:19 +00:00
wsh := handler.NewWebSocketHandler(ctx)
2017-08-24 11:51:02 +00:00
2017-09-01 06:42:23 +00:00
subscribe.Subscribe(ctx, rp.Get())
2017-09-19 08:28:21 +00:00
s.HandleSocket(conf.Config.Handlers["web"].Entry, wsh)
2017-08-24 11:51:02 +00:00
2017-09-19 08:28:21 +00:00
s.ListenAndServe(conf.Config.Server.Addr)
2017-09-01 06:42:23 +00:00
}