This commit is contained in:
crusader 2018-03-21 20:17:31 +09:00
parent bde58378b4
commit 8f3e430ac8
5 changed files with 7 additions and 32 deletions

View File

@ -1,8 +1,6 @@
package grpc package grpc
import ( import (
"fmt"
cgp "git.loafle.net/commons_go/grpc_pool" cgp "git.loafle.net/commons_go/grpc_pool"
"git.loafle.net/commons_go/logging" "git.loafle.net/commons_go/logging"
ooas "git.loafle.net/overflow/overflow_api_server/golang" ooas "git.loafle.net/overflow/overflow_api_server/golang"
@ -22,7 +20,7 @@ func ExternalInit() {
grpcPool = cgp.New(ph) grpcPool = cgp.New(ph)
if err := grpcPool.Start(); nil != err { if err := grpcPool.Start(); nil != err {
logging.Logger().Panic(fmt.Sprintf("App: %v", err)) logging.Logger().Panicf("App: %v", err)
return return
} }
} }

View File

@ -1,8 +1,6 @@
package redis package redis
import ( import (
"fmt"
"git.loafle.net/overflow/overflow_gateway_websocket/config" "git.loafle.net/overflow/overflow_gateway_websocket/config"
"git.loafle.net/commons_go/logging" "git.loafle.net/commons_go/logging"
@ -22,7 +20,7 @@ func ExternalInit() {
RedisPool = crp.New(ph) RedisPool = crp.New(ph)
if err := RedisPool.Start(); nil != err { if err := RedisPool.Start(); nil != err {
logging.Logger().Panic(fmt.Sprintf("App: %v", err)) logging.Logger().Panicf("App: %v", err)
return return
} }
} }

View File

@ -1,19 +1 @@
package overflow_gateway_websocket package overflow_gateway_websocket
import (
"flag"
cc "git.loafle.net/commons_go/config"
"git.loafle.net/overflow/overflow_gateway_websocket/config"
)
func init() {
configPath := flag.String(ConfigPathFlagName, "./", "The path of config file")
flag.Parse()
cc.SetConfigPath(*configPath)
if err := cc.Load(&config.Config, ConfigFileName); nil != err {
panic(err)
}
}

View File

@ -1,7 +1,6 @@
package server package server
import ( import (
"fmt"
"net" "net"
"time" "time"
@ -20,7 +19,7 @@ import (
func NewServerHandler() ServerHandler { func NewServerHandler() ServerHandler {
if nil == config.Config.Server { if nil == config.Config.Server {
logging.Logger().Panic(fmt.Sprintf("Gateway Websocket: Config of server is not initialized")) logging.Logger().Panicf("Gateway Websocket: Config of server is not initialized")
} }
sh := &ServerHandlers{} sh := &ServerHandlers{}
@ -71,7 +70,7 @@ func (sh *ServerHandlers) OnStart(serverCTX cwf.ServerContext) {
sh.redisSubscriber = oosr.New(redis.RedisPool.Get()) sh.redisSubscriber = oosr.New(redis.RedisPool.Get())
if err := sh.redisSubscriber.Start(); nil != err { if err := sh.redisSubscriber.Start(); nil != err {
logging.Logger().Panic(fmt.Sprintf("Gateway Websocket: Redist Subscriber did not start %v", err)) logging.Logger().Panicf("Gateway Websocket: Redist Subscriber did not start %v", err)
return return
} }
@ -95,7 +94,7 @@ func (sh *ServerHandlers) OnStop(serverCTX cwf.ServerContext) {
func (sh *ServerHandlers) RegisterServlet(servletName string, servletHandler servlet.ServletHandler) { func (sh *ServerHandlers) RegisterServlet(servletName string, servletHandler servlet.ServletHandler) {
cfg := config.Config.Servlets[servletName] cfg := config.Config.Servlets[servletName]
if nil == cfg { if nil == cfg {
logging.Logger().Panic(fmt.Sprintf("Gateway Websocket: config of servlet[%s] is not exist", servletName)) logging.Logger().Panicf("Gateway Websocket: config of servlet[%s] is not exist", servletName)
return return
} }
@ -116,7 +115,7 @@ func (sh *ServerHandlers) RegisterServlet(servletName string, servletHandler ser
func (sh *ServerHandlers) RegisterRPCGatewayServlet(servletName string, gatewayRPCHandler rpc.GatewayRPCHandler) servlet.ServletHandler { func (sh *ServerHandlers) RegisterRPCGatewayServlet(servletName string, gatewayRPCHandler rpc.GatewayRPCHandler) servlet.ServletHandler {
cfg := config.Config.Servlets[servletName] cfg := config.Config.Servlets[servletName]
if nil == cfg { if nil == cfg {
logging.Logger().Panic(fmt.Sprintf("Gateway Websocket: config of servlet[%s] is not exist", servletName)) logging.Logger().Panicf("Gateway Websocket: config of servlet[%s] is not exist", servletName)
return nil return nil
} }

View File

@ -1,8 +1,6 @@
package subscribe package subscribe
import ( import (
"fmt"
"git.loafle.net/commons_go/logging" "git.loafle.net/commons_go/logging"
cwf "git.loafle.net/commons_go/websocket_fasthttp" cwf "git.loafle.net/commons_go/websocket_fasthttp"
"git.loafle.net/overflow/overflow_gateway_websocket/servlet" "git.loafle.net/overflow/overflow_gateway_websocket/servlet"
@ -27,6 +25,6 @@ func (sh *SubscriberHandlers) Validate() {
sh.SubscriberHandlers.Validate() sh.SubscriberHandlers.Validate()
if nil == sh.ServletHandler { if nil == sh.ServletHandler {
logging.Logger().Panic(fmt.Sprintf("Gateway Websocket: servletHandler must be specified")) logging.Logger().Panicf("Gateway Websocket: servletHandler must be specified")
} }
} }