Skip to content

Commit

Permalink
embed: use default route IP for default advertise URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Romano committed Aug 13, 2016
1 parent 6e244d8 commit e145cbd
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions embed/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/coreos/etcd/discovery"
"github.com/coreos/etcd/etcdserver"
"github.com/coreos/etcd/pkg/cors"
"github.com/coreos/etcd/pkg/netutil"
"github.com/coreos/etcd/pkg/transport"
"github.com/coreos/etcd/pkg/types"
"github.com/ghodss/yaml"
Expand All @@ -33,13 +34,9 @@ const (
ClusterStateFlagNew = "new"
ClusterStateFlagExisting = "existing"

DefaultName = "default"
DefaultInitialAdvertisePeerURLs = "http://localhost:2380"
DefaultAdvertiseClientURLs = "http://localhost:2379"
DefaultListenPeerURLs = "http://localhost:2380"
DefaultListenClientURLs = "http://localhost:2379"
DefaultMaxSnapshots = 5
DefaultMaxWALs = 5
DefaultName = "default"
DefaultMaxSnapshots = 5
DefaultMaxWALs = 5

// maxElectionMs specifies the maximum value of election timeout.
// More details are listed in ../Documentation/tuning.md#time-parameters.
Expand All @@ -50,8 +47,25 @@ var (
ErrConflictBootstrapFlags = fmt.Errorf("multiple discovery or bootstrap flags are set. " +
"Choose one of \"initial-cluster\", \"discovery\" or \"discovery-srv\"")
ErrUnsetAdvertiseClientURLsFlag = fmt.Errorf("--advertise-client-urls is required when --listen-client-urls is set explicitly")

DefaultListenPeerURLs = "http://localhost:2380"
DefaultListenClientURLs = "http://localhost:2379"
DefaultInitialAdvertisePeerURLs = "http://localhost:2380"
DefaultAdvertiseClientURLs = "http://localhost:2379"
)

func init() {
ip, err := netutil.GetDefaultHost()
if err != nil {
return
}
// found default host; listen everywhere, advertise on default host
DefaultListenPeerURLs = "http://0.0.0.0:2380"
DefaultListenClientURLs = "http://0.0.0.0:2379"
DefaultInitialAdvertisePeerURLs = "http://" + ip + ":2380"
DefaultAdvertiseClientURLs = "http://" + ip + ":2379"
}

// Config holds the arguments for configuring an etcd server.
type Config struct {
// member
Expand Down

0 comments on commit e145cbd

Please sign in to comment.