mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdmain: add retry-delay flag
This commit is contained in:
parent
62e5ffac13
commit
9a6daefb3e
@ -18,7 +18,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"time"
|
||||||
|
|
||||||
"github.com/coreos/etcd/proxy/tcpproxy"
|
"github.com/coreos/etcd/proxy/tcpproxy"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -26,7 +26,8 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
gatewayListenAddr string
|
gatewayListenAddr string
|
||||||
gatewayEndpoints string
|
gatewayEndpoints []string
|
||||||
|
getewayRetryDelay time.Duration
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -60,14 +61,13 @@ func newGatewayStartCommand() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().StringVar(&gatewayListenAddr, "listen-addr", "127.0.0.1:23790", "listen address")
|
cmd.Flags().StringVar(&gatewayListenAddr, "listen-addr", "127.0.0.1:23790", "listen address")
|
||||||
cmd.Flags().StringVar(&gatewayEndpoints, "endpoints", "127.0.0.1:2379", "comma separated etcd cluster endpoints")
|
cmd.Flags().StringSliceVar(&gatewayEndpoints, "endpoints", []string{"127.0.0.1:2379"}, "comma separated etcd cluster endpoints")
|
||||||
|
cmd.Flags().DurationVar(&getewayRetryDelay, "retry-delay", time.Minute, "duration of delay before retrying failed endpoints")
|
||||||
|
|
||||||
return &cmd
|
return &cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func startGateway(cmd *cobra.Command, args []string) {
|
func startGateway(cmd *cobra.Command, args []string) {
|
||||||
endpoints := strings.Split(gatewayEndpoints, ",")
|
|
||||||
|
|
||||||
l, err := net.Listen("tcp", gatewayListenAddr)
|
l, err := net.Listen("tcp", gatewayListenAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
@ -75,8 +75,9 @@ func startGateway(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tp := tcpproxy.TCPProxy{
|
tp := tcpproxy.TCPProxy{
|
||||||
Listener: l,
|
Listener: l,
|
||||||
Endpoints: endpoints,
|
Endpoints: gatewayEndpoints,
|
||||||
|
MonitorInterval: getewayRetryDelay,
|
||||||
}
|
}
|
||||||
|
|
||||||
tp.Run()
|
tp.Run()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user