Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -http-port option to change the HTTP API port #1167

Merged
merged 6 commits into from
Sep 2, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions command/agent/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func (c *Command) readConfig() *Config {

cmdFlags.StringVar(&cmdConfig.ClientAddr, "client", "", "address to bind client listeners to (DNS, HTTP, HTTPS, RPC)")
cmdFlags.StringVar(&cmdConfig.BindAddr, "bind", "", "address to bind server listeners to")
cmdFlags.IntVar(&cmdConfig.HttpPort, "http-port", 0, "http port to use")
cmdFlags.StringVar(&cmdConfig.AdvertiseAddr, "advertise", "", "address to advertise instead of bind addr")
cmdFlags.StringVar(&cmdConfig.AdvertiseAddrWan, "advertise-wan", "", "address to advertise on wan instead of bind or advertise addr")

Expand Down
8 changes: 8 additions & 0 deletions command/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ type Config struct {
// client services (DNS, HTTP, HTTPS, RPC)
ClientAddr string `mapstructure:"client_addr"`

// HttpPort the HTTP port to listen on.
// This is useful e.g. when deploying to Cloud Foundry to make
// the HTTP API easily routable
HttpPort int `mapstructure:"http_port"`

// BindAddr is used to control the address we bind to.
// If not specified, the first private IP we find is used.
// This controls the address we use for cluster facing
Expand Down Expand Up @@ -849,6 +854,9 @@ func MergeConfig(a, b *Config) *Config {
if b.BindAddr != "" {
result.BindAddr = b.BindAddr
}
if b.HttpPort != 0 {
result.Ports.HTTP = b.HttpPort
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test case to ensure this merging works? There are examples in config_test.go that you can piggyback on.

if b.AdvertiseAddr != "" {
result.AdvertiseAddr = b.AdvertiseAddr
}
Expand Down