fix: golint code format and error log trace (#1259)
This commit is contained in:
parent
088b143300
commit
ba190fde13
|
@ -18,9 +18,12 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// RunWsAndServer run ws server
|
||||||
func RunWsAndServer(rpcPort, wsPort, prometheusPort int) error {
|
func RunWsAndServer(rpcPort, wsPort, prometheusPort int) error {
|
||||||
fmt.Println(
|
fmt.Println(
|
||||||
"start rpc/msg_gateway server, port: ",
|
"start rpc/msg_gateway server, port: ",
|
||||||
|
@ -42,7 +45,7 @@ func RunWsAndServer(rpcPort, wsPort, prometheusPort int) error {
|
||||||
go func() {
|
go func() {
|
||||||
err := hubServer.Start()
|
err := hubServer.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err.Error())
|
panic(utils.Wrap1(err))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return hubServer.LongConnServer.Run()
|
return hubServer.LongConnServer.Run()
|
||||||
|
|
|
@ -23,6 +23,7 @@ import (
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -12,4 +12,5 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package startrpc // import "github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
// Package startrpc start rpc server.
|
||||||
|
package startrpc
|
||||||
|
|
|
@ -16,11 +16,12 @@ package startrpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/discovery_register"
|
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/common/discovery_register"
|
||||||
|
|
||||||
grpcprometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
grpcprometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials/insecure"
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
|
@ -32,6 +33,7 @@ import (
|
||||||
"github.com/OpenIMSDK/tools/utils"
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Start rpc server.
|
||||||
func Start(
|
func Start(
|
||||||
rpcPort int,
|
rpcPort int,
|
||||||
rpcRegisterName string,
|
rpcRegisterName string,
|
||||||
|
@ -39,16 +41,8 @@ func Start(
|
||||||
rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error,
|
rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error,
|
||||||
options ...grpc.ServerOption,
|
options ...grpc.ServerOption,
|
||||||
) error {
|
) error {
|
||||||
fmt.Println(
|
fmt.Printf("start %s server, port: %d, prometheusPort: %d, OpenIM version: %s",
|
||||||
"start",
|
rpcRegisterName, rpcPort, prometheusPort, config.Version)
|
||||||
rpcRegisterName,
|
|
||||||
"server, port: ",
|
|
||||||
rpcPort,
|
|
||||||
"prometheusPort:",
|
|
||||||
prometheusPort,
|
|
||||||
", OpenIM version: ",
|
|
||||||
config.Version,
|
|
||||||
)
|
|
||||||
listener, err := net.Listen(
|
listener, err := net.Listen(
|
||||||
"tcp",
|
"tcp",
|
||||||
net.JoinHostPort(network.GetListenIP(config.Config.Rpc.ListenIP), strconv.Itoa(rpcPort)),
|
net.JoinHostPort(network.GetListenIP(config.Config.Rpc.ListenIP), strconv.Itoa(rpcPort)),
|
||||||
|
@ -63,11 +57,10 @@ func Start(
|
||||||
zookeeper.WithFreq(time.Hour), zookeeper.WithUserNameAndPassword(
|
zookeeper.WithFreq(time.Hour), zookeeper.WithUserNameAndPassword(
|
||||||
config.Config.Zookeeper.Username,
|
config.Config.Zookeeper.Username,
|
||||||
config.Config.Zookeeper.Password,
|
config.Config.Zookeeper.Password,
|
||||||
), zookeeper.WithRoundRobin(), zookeeper.WithTimeout(10), zookeeper.WithLogger(log.NewZkLogger()))*/
|
), zookeeper.WithRoundRobin(), zookeeper.WithTimeout(10), zookeeper.WithLogger(log.NewZkLogger()))*/if err != nil {
|
||||||
if err != nil {
|
|
||||||
return utils.Wrap1(err)
|
return utils.Wrap1(err)
|
||||||
}
|
}
|
||||||
//defer zkClient.CloseZK()
|
// defer zkClient.CloseZK()
|
||||||
zkClient.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
zkClient.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||||
registerIP, err := network.GetRpcRegisterIP(config.Config.Rpc.RegisterIP)
|
registerIP, err := network.GetRpcRegisterIP(config.Config.Rpc.RegisterIP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -108,5 +101,6 @@ func Start(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return utils.Wrap1(srv.Serve(listener))
|
return utils.Wrap1(srv.Serve(listener))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue