ing
This commit is contained in:
parent
55016583d4
commit
f854dbf21d
31
main.go
31
main.go
|
@ -1,18 +1,38 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"flag"
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
cc "git.loafle.net/commons_go/config"
|
||||||
"git.loafle.net/commons_go/logging"
|
"git.loafle.net/commons_go/logging"
|
||||||
|
oocc "git.loafle.net/overflow/overflow_commons_go/config"
|
||||||
"git.loafle.net/overflow/overflow_gateway_webapp/server"
|
"git.loafle.net/overflow/overflow_gateway_webapp/server"
|
||||||
"git.loafle.net/overflow/overflow_gateway_webapp/servlet"
|
"git.loafle.net/overflow/overflow_gateway_webapp/servlet"
|
||||||
|
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/config"
|
||||||
oogws "git.loafle.net/overflow/overflow_gateway_websocket/server"
|
oogws "git.loafle.net/overflow/overflow_gateway_websocket/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
configDir *string
|
||||||
|
logConfigPath *string
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
configDir = oocc.FlagConfigDir("./")
|
||||||
|
logConfigPath = oocc.FlagLogConfigFilePath("")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
logging.InitializeLogger(*logConfigPath)
|
||||||
|
|
||||||
|
cc.SetConfigPath(*configDir)
|
||||||
|
if err := cc.Load(&oogwc.Config, oocc.ConfigFileName); nil != err {
|
||||||
|
logging.Logger().Panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
defer logging.Logger().Sync()
|
defer logging.Logger().Sync()
|
||||||
|
|
||||||
|
@ -26,16 +46,17 @@ func main() {
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if err := s.Start(); nil != err {
|
if err := s.Start(); nil != err {
|
||||||
log.Printf("Server: Start error %v", err)
|
logging.Logger().Infof("Server: Start error %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case signal := <-stop:
|
case signal := <-stop:
|
||||||
fmt.Printf("Got signal: %v\n", signal)
|
logging.Logger().Infof("Got signal: %v\n", signal)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
servlet.ServletDestroy()
|
||||||
s.Stop()
|
s.Stop()
|
||||||
|
logging.Logger().Infof("Server stopped")
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ func (sh *GatewayRPCHandlers) Handshake(socketCTX cwf.SocketContext, ctx *fastht
|
||||||
|
|
||||||
var claims jwt.MapClaims
|
var claims jwt.MapClaims
|
||||||
if claims, ok = token.Claims.(jwt.MapClaims); !ok || !token.Valid {
|
if claims, ok = token.Claims.(jwt.MapClaims); !ok || !token.Valid {
|
||||||
logging.Logger().Warn(fmt.Sprintf("Webapp: Token is not valid %v", token))
|
logging.Logger().Warnf("Webapp: Token is not valid %v", token)
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package webapp
|
package webapp
|
||||||
|
|
||||||
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/commons_go/websocket_fasthttp/websocket"
|
"git.loafle.net/commons_go/websocket_fasthttp/websocket"
|
||||||
|
@ -45,7 +43,7 @@ func (sh *SubscriberHandlers) OnSubscribe(channel string, message oos.SubscribeM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
logging.Logger().Warn(fmt.Sprintf("[WEBAPP] SubscriberHandler: Unknown TargetType %s", message.TargetType))
|
logging.Logger().Warnf("[WEBAPP] SubscriberHandler: Unknown TargetType %s", message.TargetType)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package webapp
|
package webapp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"git.loafle.net/commons_go/logging"
|
"git.loafle.net/commons_go/logging"
|
||||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/config"
|
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/config"
|
||||||
oogws "git.loafle.net/overflow/overflow_gateway_websocket/server"
|
oogws "git.loafle.net/overflow/overflow_gateway_websocket/server"
|
||||||
|
@ -20,7 +18,7 @@ var (
|
||||||
func ServletInit(sh oogws.ServerHandler) {
|
func ServletInit(sh oogws.ServerHandler) {
|
||||||
cfg = oogwc.Config.Servlets[Name]
|
cfg = oogwc.Config.Servlets[Name]
|
||||||
if nil == cfg {
|
if nil == cfg {
|
||||||
logging.Logger().Panic(fmt.Sprintf("WebApp: config of servlet[%s] is not exist", Name))
|
logging.Logger().Panicf("WebApp: config of servlet[%s] is not exist", Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcGH := newGatewayRPCHandler()
|
rpcGH := newGatewayRPCHandler()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user