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

bind on specific address #195

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions config.toml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# that can be resovled here.
# hostname = ""

# bind_address = "127.0.0.1"

[logging]
# logging level can be one of "debug", "info", "warn" or "error"
level = "info"
Expand Down
9 changes: 6 additions & 3 deletions src/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type TomlConfiguration struct {
Cluster ClusterConfig
Logging LoggingConfig
Hostname string
BindAddress string `toml:"bind-address"`
}

type Configuration struct {
Expand All @@ -59,6 +60,7 @@ type Configuration struct {
Hostname string
LogFile string
LogLevel string
BindAddress string
}

func LoadConfiguration(fileName string) *Configuration {
Expand Down Expand Up @@ -93,6 +95,7 @@ func parseTomlConfiguration(filename string) (*Configuration, error) {
LogFile: tomlConfiguration.Logging.File,
LogLevel: tomlConfiguration.Logging.Level,
Hostname: tomlConfiguration.Hostname,
BindAddress: tomlConfiguration.BindAddress,
}

return config, nil
Expand All @@ -117,15 +120,15 @@ func parseJsonConfiguration(fileName string) (*Configuration, error) {
}

func (self *Configuration) AdminHttpPortString() string {
return fmt.Sprintf(":%d", self.AdminHttpPort)
return fmt.Sprintf("%s:%d", self.BindAddress, self.AdminHttpPort)
}

func (self *Configuration) ApiHttpPortString() string {
return fmt.Sprintf(":%d", self.ApiHttpPort)
return fmt.Sprintf("%s:%d", self.BindAddress, self.ApiHttpPort)
}

func (self *Configuration) ProtobufPortString() string {
return fmt.Sprintf(":%d", self.ProtobufPort)
return fmt.Sprintf("%s:%d", self.BindAddress, self.ProtobufPort)
}

func (self *Configuration) HostnameOrDetect() string {
Expand Down
4 changes: 3 additions & 1 deletion src/coordinator/raft_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type RaftServer struct {
host string
port int
path string
bind_address string
router *mux.Router
raftServer raft.Server
httpServer *http.Server
Expand Down Expand Up @@ -69,6 +70,7 @@ func NewRaftServer(config *configuration.Configuration, clusterConfig *ClusterCo
host: config.HostnameOrDetect(),
port: config.RaftServerPort,
path: config.RaftDir,
bind_address: config.BindAddress,
clusterConfig: clusterConfig,
notLeader: make(chan bool, 1),
router: mux.NewRouter(),
Expand Down Expand Up @@ -449,7 +451,7 @@ func (s *RaftServer) runContinuousQuery(db string, query *parser.SelectQuery, st
}

func (s *RaftServer) ListenAndServe() error {
l, err := net.Listen("tcp", fmt.Sprintf(":%d", s.port))
l, err := net.Listen("tcp", fmt.Sprintf("%s:%d", s.bind_address, s.port))
if err != nil {
panic(err)
}
Expand Down
8 changes: 6 additions & 2 deletions src/daemon/influxd.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,12 @@ func main() {
panic(err)
}
}

log.Info("Starting Influx Server...")

if config.BindAddress == "" {
log.Info("Starting Influx Server...")
} else {
log.Info("Starting Influx Server bound to %s ...", config.BindAddress)
}
log.Info(`
+---------------------------------------------+
| _____ __ _ _____ ____ |
Expand Down