rpc restore

This commit is contained in:
Gordon
2021-12-17 15:55:43 +08:00
parent 42726cf2b6
commit d6614decd1
7 changed files with 31 additions and 43 deletions
+4 -6
View File
@@ -14,13 +14,11 @@ import (
pbGroup "Open_IM/pkg/proto/group"
"Open_IM/pkg/utils"
"context"
"google.golang.org/grpc"
"net"
"strconv"
"strings"
"time"
"github.com/spf13/viper"
"google.golang.org/grpc"
)
type groupServer struct {
@@ -42,7 +40,8 @@ func NewGroupServer(port int) *groupServer {
func (s *groupServer) Run() {
log.Info("", "", "rpc group init....")
registerAddress := ":" + strconv.Itoa(s.rpcPort)
ip := utils.ServerIP
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", registerAddress)
if err != nil {
@@ -56,8 +55,7 @@ func (s *groupServer) Run() {
defer srv.GracefulStop()
//Service registers with etcd
pbGroup.RegisterGroupServer(srv, s)
host := viper.GetString("endpoints.rpc_group")
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), host, s.rpcPort, s.rpcRegisterName, 10)
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
if err != nil {
log.ErrorByArgs("get etcd failed,err=%s", err.Error())
return