ing
This commit is contained in:
parent
2d6345b493
commit
637cdaca24
10
config.json
10
config.json
|
@ -15,5 +15,15 @@
|
|||
"pingTimeout": 10,
|
||||
"pingPeriod": 10,
|
||||
"enableCompression": false
|
||||
},
|
||||
"external": {
|
||||
"grpc": {
|
||||
"network": "tcp4",
|
||||
"address": "192.168.1.50:50006"
|
||||
},
|
||||
"redis": {
|
||||
"network": "tcp4",
|
||||
"address": "192.168.1.50:6379"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"git.loafle.net/commons/server-go/socket/web"
|
||||
occe "git.loafle.net/overflow/commons-go/config/external"
|
||||
ogrs "git.loafle.net/overflow/gateway_rpc/server"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
ServerHandler web.ServerHandlers `json:"serverHandler"`
|
||||
ServerHandler *ogrs.ServerHandlers `json:"serverHandler"`
|
||||
External *occe.External `json:"external"`
|
||||
}
|
||||
|
|
6
main.go
6
main.go
|
@ -28,13 +28,13 @@ func init() {
|
|||
}
|
||||
|
||||
func main() {
|
||||
config := &config.Config{}
|
||||
_config := &config.Config{}
|
||||
configuration.SetConfigPath(*configDir)
|
||||
if err := configuration.Load(config, "config.json"); nil != err {
|
||||
if err := configuration.Load(_config, "config.json"); nil != err {
|
||||
logging.Logger().Panic(err)
|
||||
}
|
||||
|
||||
s := server.New()
|
||||
s := server.New(_config)
|
||||
|
||||
go func() {
|
||||
err := s.ListenAndServe()
|
||||
|
|
|
@ -2,7 +2,9 @@ package server
|
|||
|
||||
import (
|
||||
cs "git.loafle.net/commons/server-go"
|
||||
oge "git.loafle.net/overflow/gateway/external"
|
||||
ogrs "git.loafle.net/overflow/gateway_rpc/server"
|
||||
"git.loafle.net/overflow/member_gateway_rpc/config"
|
||||
"git.loafle.net/overflow/member_gateway_rpc/subscribe"
|
||||
)
|
||||
|
||||
|
@ -12,13 +14,15 @@ type ServerHandler interface {
|
|||
|
||||
type ServerHandlers struct {
|
||||
ogrs.ServerHandlers
|
||||
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
func (sh *ServerHandlers) Init(serverCtx cs.ServerCtx) error {
|
||||
if err := sh.ServerHandlers.Init(serverCtx); nil != err {
|
||||
return err
|
||||
}
|
||||
|
||||
oge.InitPackage(sh.Config.External)
|
||||
subscribe.InitPackage()
|
||||
|
||||
return nil
|
||||
|
@ -29,6 +33,7 @@ func (sh *ServerHandlers) OnStart(serverCtx cs.ServerCtx) error {
|
|||
return err
|
||||
}
|
||||
|
||||
oge.StartPackage(sh.Config.External)
|
||||
subscribe.StartPackage()
|
||||
|
||||
return nil
|
||||
|
@ -36,12 +41,14 @@ func (sh *ServerHandlers) OnStart(serverCtx cs.ServerCtx) error {
|
|||
|
||||
func (sh *ServerHandlers) OnStop(serverCtx cs.ServerCtx) {
|
||||
subscribe.StopPackage()
|
||||
oge.StopPackage(sh.Config.External)
|
||||
|
||||
sh.ServerHandlers.OnStop(serverCtx)
|
||||
}
|
||||
|
||||
func (sh *ServerHandlers) Destroy(serverCtx cs.ServerCtx) {
|
||||
subscribe.DestroyPackage()
|
||||
oge.DestroyPackage(sh.Config.External)
|
||||
|
||||
sh.ServerHandlers.Destroy(serverCtx)
|
||||
}
|
||||
|
|
|
@ -2,12 +2,17 @@ package server
|
|||
|
||||
import (
|
||||
csgw "git.loafle.net/commons/server-go/socket/web"
|
||||
"git.loafle.net/overflow/member_gateway_rpc/config"
|
||||
"git.loafle.net/overflow/member_gateway_rpc/servlet"
|
||||
)
|
||||
|
||||
func New() *csgw.Server {
|
||||
func New(_config *config.Config) *csgw.Server {
|
||||
ws := &servlet.WebappServlets{}
|
||||
sh := &ServerHandlers{}
|
||||
sh := &ServerHandlers{
|
||||
ServerHandlers: *_config.ServerHandler,
|
||||
Config: _config,
|
||||
}
|
||||
|
||||
sh.RegisterServlet("/webapp", ws)
|
||||
|
||||
s := &csgw.Server{
|
||||
|
|
|
@ -10,23 +10,23 @@ var Subscriber *ogsr.Subscribers
|
|||
|
||||
func InitPackage() {
|
||||
Subscriber = &ogsr.Subscribers{}
|
||||
}
|
||||
|
||||
func StartPackage() {
|
||||
Subscriber.Conn = oger.Pool.Get()
|
||||
if err := Subscriber.Start(); nil != err {
|
||||
logging.Logger().Panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func StartPackage() {
|
||||
}
|
||||
|
||||
func StopPackage() {
|
||||
}
|
||||
|
||||
func DestroyPackage() {
|
||||
if nil != Subscriber {
|
||||
if err := Subscriber.Stop(); nil != err {
|
||||
logging.Logger().Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func DestroyPackage() {
|
||||
Subscriber = nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user