diff --git a/main.go b/main.go index 680758e..0202fcf 100644 --- a/main.go +++ b/main.go @@ -29,7 +29,7 @@ func main() { flag.Parse() if err := runProxying(localAddr, sentinelAddr, masterName, masterResolveRetries); err != nil { - log.Fatalln(err) + log.Fatalf("Fatal: %s", err) } log.Println("Exiting...") } @@ -47,14 +47,13 @@ func runProxying(localAddr, sentinelAddr, masterName string, masterResolveRetrie eg, ctx := errgroup.WithContext(ctx) eg.Go(func() error { return masterAddrResolver.UpdateMasterAddressLoop(ctx) }) eg.Go(func() error { return rsp.Run(ctx) }) - return eg.Wait() } func resolveTCPAddr(addr string) *net.TCPAddr { tcpAddr, err := net.ResolveTCPAddr("tcp", addr) if err != nil { - log.Fatalf("Failed resolving tcp address: %s", err) + log.Fatalf("Fatal - Failed resolving tcp address: %s", err) } return tcpAddr } diff --git a/pkg/master_resolver/master_resolver.go b/pkg/master_resolver/master_resolver.go index fd6c5ea..e133152 100644 --- a/pkg/master_resolver/master_resolver.go +++ b/pkg/master_resolver/master_resolver.go @@ -91,6 +91,7 @@ func (r *RedisMasterResolver) initialMasterAdressResolve() error { func redisMasterFromSentinelAddr(sentinelAddress *net.TCPAddr, masterName string) (*net.TCPAddr, error) { conn, err := utils.TCPConnectWithTimeout(sentinelAddress.String()) + conn.SetDeadline(time.Now().Add(time.Second)) if err != nil { return nil, fmt.Errorf("error connecting to sentinel: %w", err) }