Rpc Register IP

This commit is contained in:
wenxu12345 2022-06-23 09:24:05 +08:00
parent e4d35c2a86
commit 218340e138
13 changed files with 16 additions and 13 deletions

View File

@ -55,7 +55,7 @@ func (r *RPCServer) run() {
defer srv.GracefulStop()
pbRelay.RegisterOnlineMessageRelayServiceServer(srv, r)
rpcRegisterIP := ""
rpcRegisterIP := config.Config.RpcRegisterIP
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
@ -291,9 +291,11 @@ func (r *RPCServer) KickUserOffline(_ context.Context, req *pbRelay.KickUserOffl
for _, v := range req.KickUserIDList {
oldConnMap := ws.getUserAllCons(v)
if conn, ok := oldConnMap[int(req.PlatformID)]; ok { // user->map[platform->conn]
log.NewWarn(req.OperationID, "send kick msg, close connection ", req.PlatformID, v)
ws.sendKickMsg(conn, &UserConn{})
conn.Close()
}
log.NewWarn(req.OperationID, "SetTokenKicked ", v, req.PlatformID, req.OperationID)
SetTokenKicked(v, int(req.PlatformID), req.OperationID)
}
return &pbRelay.KickUserOfflineResp{}, nil

View File

@ -44,7 +44,7 @@ func (r *RPCServer) run() {
srv := grpc.NewServer()
defer srv.GracefulStop()
pbPush.RegisterPushMsgServiceServer(srv, r)
rpcRegisterIP := ""
rpcRegisterIP := config.Config.RpcRegisterIP
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {

View File

@ -56,7 +56,7 @@ func (s *adminCMSServer) Run() {
defer srv.GracefulStop()
//Service registers with etcd
pbAdminCMS.RegisterAdminCMSServer(srv, s)
rpcRegisterIP := ""
rpcRegisterIP := config.Config.RpcRegisterIP
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {

View File

@ -134,7 +134,7 @@ func (rpc *rpcAuth) Run() {
//service registers with etcd
pbAuth.RegisterAuthServer(srv, rpc)
rpcRegisterIP := ""
rpcRegisterIP := config.Config.RpcRegisterIP
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
@ -142,6 +142,7 @@ func (rpc *rpcAuth) Run() {
}
}
log.NewInfo("", "rpcRegisterIP", rpcRegisterIP)
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
if err != nil {
log.NewError(operationID, "RegisterEtcd failed ", err.Error(),

View File

@ -65,7 +65,7 @@ func (s *cacheServer) Run() {
defer srv.GracefulStop()
pbCache.RegisterCacheServer(srv, s)
rpcRegisterIP := ""
rpcRegisterIP := config.Config.RpcRegisterIP
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {

View File

@ -157,7 +157,7 @@ func (rpc *rpcConversation) Run() {
//service registers with etcd
pbConversation.RegisterConversationServer(srv, rpc)
rpcRegisterIP := ""
rpcRegisterIP := config.Config.RpcRegisterIP
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {

View File

@ -66,7 +66,7 @@ func (s *groupServer) Run() {
pbGroup.RegisterGroupServer(srv, s)
rpcRegisterIP := config.Config.RpcRegisterIP
if rpcRegisterIP == "" {
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
log.Error("", "GetLocalIP failed ", err.Error())

View File

@ -63,7 +63,7 @@ func (s *messageCMSServer) Run() {
defer srv.GracefulStop()
//Service registers with etcd
pbMessageCMS.RegisterMessageCMSServer(srv, s)
rpcRegisterIP := ""
rpcRegisterIP := config.Config.RpcRegisterIP
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {

View File

@ -64,7 +64,7 @@ func (rpc *rpcChat) Run() {
srv := grpc.NewServer()
defer srv.GracefulStop()
rpcRegisterIP := ""
rpcRegisterIP := config.Config.RpcRegisterIP
pbChat.RegisterChatServer(srv, rpc)
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()

View File

@ -71,7 +71,7 @@ func (s *officeServer) Run() {
defer srv.GracefulStop()
//Service registers with etcd
pbOffice.RegisterOfficeServiceServer(srv, s)
rpcRegisterIP := ""
rpcRegisterIP := config.Config.RpcRegisterIP
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {

View File

@ -61,7 +61,7 @@ func (s *organizationServer) Run() {
defer srv.GracefulStop()
//Service registers with etcd
rpc.RegisterOrganizationServer(srv, s)
rpcRegisterIP := ""
rpcRegisterIP := config.Config.RpcRegisterIP
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {

View File

@ -67,7 +67,7 @@ func (s *statisticsServer) Run() {
defer srv.GracefulStop()
//Service registers with etcd
pbStatistics.RegisterUserServer(srv, s)
rpcRegisterIP := ""
rpcRegisterIP := config.Config.RpcRegisterIP
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {

View File

@ -62,7 +62,7 @@ func (s *userServer) Run() {
defer srv.GracefulStop()
//Service registers with etcd
pbUser.RegisterUserServer(srv, s)
rpcRegisterIP := ""
rpcRegisterIP := config.Config.RpcRegisterIP
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {