Skip to content

Commit

Permalink
Merge branch 'openimsdk:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
withchao authored Oct 25, 2023
2 parents 2ccfe25 + 72bb2d5 commit 02acbfe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
13 changes: 7 additions & 6 deletions pkg/common/chatrpcstart/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ import (

func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error, options ...grpc.ServerOption) error {
fmt.Println("start", rpcRegisterName, "server, port: ", rpcPort, "prometheusPort:", prometheusPort, ", OpenIM version: ", config.Version)
listener, err := net.Listen("tcp", net.JoinHostPort(network.GetListenIP(config.Config.Rpc.ListenIP), strconv.Itoa(rpcPort)))
if err != nil {
return err
}
defer listener.Close()

zkClient, err := openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
openKeeper.WithFreq(time.Hour), openKeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username,
config.Config.Zookeeper.Password), openKeeper.WithRoundRobin(), openKeeper.WithTimeout(10), openKeeper.WithLogger(log.NewZkLogger()))
Expand All @@ -50,7 +46,7 @@ func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(c
zkClient.AddOption(chatMw.AddUserType(), mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()))
registerIP, err := network.GetRpcRegisterIP(config.Config.Rpc.RegisterIP)
if err != nil {
return err
return utils.Wrap1(err)
}
srv := grpc.NewServer(append(options, mw.GrpcServer())...)
defer srv.GracefulStop()
Expand All @@ -62,5 +58,10 @@ func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(c
if err != nil {
return utils.Wrap1(err)
}
listener, err := net.Listen("tcp", net.JoinHostPort(network.GetListenIP(config.Config.Rpc.ListenIP), strconv.Itoa(rpcPort)))
if err != nil {
return utils.Wrap1(err)
}
defer listener.Close()
return utils.Wrap1(srv.Serve(listener))
}
8 changes: 7 additions & 1 deletion scripts/start_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,14 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do
list_to_string ${portList}
service_ports=($ports_array)


#Start related rpc services based on the number of ports
for ((j = 0; j < ${#service_ports[*]}; j++)); do
if [ ! -e "$bin_dir/${service_filename[$i]}" ]; then
echo -e ${RED_PREFIX}"Error: ${service_filename[$i]} does not exist,Start fail!"${COLOR_SUFFIX}
echo "start build these binary"
"./build_all_service.sh"
fi
#Start the service in the background
cmd="$bin_dir/${service_filename[$i]} -port ${service_ports[$j]} --config_folder_path ${config_path}"
if [ $i -eq 0 -o $i -eq 1 ]; then
Expand All @@ -102,4 +108,4 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do
# pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1"
# echo -e "${GREEN_PREFIX}${service_filename[$i]} start success,port number:${service_ports[$j]} pid:$(eval $pid)$COLOR_SUFFIX"
done
done
done

0 comments on commit 02acbfe

Please sign in to comment.