From 8f4ca49c760370d9552d4abca34f751cdf5bbb47 Mon Sep 17 00:00:00 2001 From: lance6716 Date: Thu, 24 Aug 2023 10:55:18 +0800 Subject: [PATCH] update log Signed-off-by: lance6716 --- .../backend/local/mockserver/main/main.go | 3 ++- .../backend/local/mockserver/main2/main.go | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/br/pkg/lightning/backend/local/mockserver/main/main.go b/br/pkg/lightning/backend/local/mockserver/main/main.go index 92d6ef5472ff8..47cb4628bc891 100644 --- a/br/pkg/lightning/backend/local/mockserver/main/main.go +++ b/br/pkg/lightning/backend/local/mockserver/main/main.go @@ -26,7 +26,8 @@ import ( ) func main() { - lis, err := net.Listen("tcp", ":0") + portStr := os.Args[1] + lis, err := net.Listen("tcp", ":"+portStr) if err != nil { log.Fatal(err) } diff --git a/br/pkg/lightning/backend/local/mockserver/main2/main.go b/br/pkg/lightning/backend/local/mockserver/main2/main.go index b9a0cf2d4324b..7306ba71a43c1 100644 --- a/br/pkg/lightning/backend/local/mockserver/main2/main.go +++ b/br/pkg/lightning/backend/local/mockserver/main2/main.go @@ -17,10 +17,11 @@ package main import ( "context" "fmt" - "log" "os" sst "github.com/pingcap/kvproto/pkg/import_sstpb" + "github.com/pingcap/log" + "go.uber.org/zap" "google.golang.org/grpc" ) @@ -29,13 +30,14 @@ func main() { conn, err := grpc.DialContext(ctx, os.Args[1], grpc.WithInsecure()) if err != nil { - log.Fatal(err) + log.Fatal("fail to dial", zap.Error(err)) } for { client := sst.NewImportSSTClient(conn) stream, err := client.Write(ctx) if err != nil { - log.Fatal(err) + log.Error("fail to write", zap.Error(err)) + continue } err = stream.Send(&sst.WriteRequest{ Chunk: &sst.WriteRequest_Meta{ @@ -45,11 +47,13 @@ func main() { }, }) if err != nil { - log.Fatal(err) + log.Error("fail to send", zap.Error(err)) + continue } resp, err := stream.CloseAndRecv() if err != nil { - log.Fatal(err) + log.Error("fail to close and recv", zap.Error(err)) + continue } fmt.Printf("resp: %v\n", resp) }