diff --git a/cmd/influxd/config.go b/cmd/influxd/config.go index 2ff6b68c23..cbb83b6a2d 100644 --- a/cmd/influxd/config.go +++ b/cmd/influxd/config.go @@ -36,6 +36,9 @@ const ( // DefaultDataPort represents the default port the data server runs on. DefaultDataPort = 8086 + + // DefaultJoinURLs represents the default URLs for joining a cluster. + DefaultJoinURLs = "" ) // Config represents the configuration format for the influxd binary. @@ -46,6 +49,10 @@ type Config struct { Version string `toml:"-"` InfluxDBVersion string `toml:"-"` + Initialization struct { + JoinURLs string `toml:"join-urls"` + } + Authentication struct { Enabled bool `toml:"enabled"` } `toml:"authentication"` @@ -216,6 +223,14 @@ func (c *Config) DataDir() string { return p } +func (c *Config) JoinURLs() string { + if c.Initialization.JoinURLs == "" { + return DefaultJoinURLs + } else { + return c.Initialization.JoinURLs + } +} + // Size represents a TOML parseable file size. // Users can specify size using "m" for megabytes and "g" for gigabytes. type Size int diff --git a/cmd/influxd/config_test.go b/cmd/influxd/config_test.go index 06fda9e005..acfd6d2630 100644 --- a/cmd/influxd/config_test.go +++ b/cmd/influxd/config_test.go @@ -42,6 +42,10 @@ func TestParseConfig(t *testing.T) { t.Fatalf("hostname mismatch: %v", c.Hostname) } + if c.JoinURLs() != "http://127.0.0.1:8086" { + t.Fatalf("JoinURLs mistmatch: %v", c.JoinURLs()) + } + if c.Logging.File != "influxdb.log" { t.Fatalf("logging file mismatch: %v", c.Logging.File) } else if c.Logging.Level != "info" { @@ -155,6 +159,11 @@ const testFile = ` # that can be resolved here. hostname = "myserver.com" +# Controls certain parameters that only take effect until an initial successful +# start-up has occurred. +[initialization] +join-urls = "http://127.0.0.1:8086" + # Control authentication [authentication] enabled = true diff --git a/cmd/influxd/run.go b/cmd/influxd/run.go index c26a5aab12..5b5533319e 100644 --- a/cmd/influxd/run.go +++ b/cmd/influxd/run.go @@ -31,9 +31,6 @@ func execRun(args []string) { fs.Usage = printRunUsage fs.Parse(args) - // Parse join urls from the --join flag. - joinURLs := parseURLs(*join) - // Print sweet InfluxDB logo and write the process id to file. log.Print(logo) log.SetPrefix(`[srvr] `) @@ -45,6 +42,14 @@ func execRun(args []string) { configExists := *configPath != "" initializing := !fileExists(config.BrokerDir()) && !fileExists(config.DataDir()) + // Parse join urls from the --join flag. + var joinURLs []*url.URL + if *join == "" { + joinURLs = parseURLs(config.JoinURLs()) + } else { + joinURLs = parseURLs(*join) + } + // Open broker, initialize or join as necessary. b := openBroker(config.BrokerDir(), config.BrokerURL(), initializing, joinURLs) diff --git a/etc/config.sample.toml b/etc/config.sample.toml index 8582bb67b6..df8e6b0451 100644 --- a/etc/config.sample.toml +++ b/etc/config.sample.toml @@ -15,6 +15,11 @@ bind-address = "0.0.0.0" # Change this option to true to disable reporting. reporting-disabled = false +# Controls settings for initial start-up. Once a node a successfully started, +# these settings no longer apply. +[initialization] +join-urls = "" + # Control authentication # If not set authetication is DISABLED. Be sure to explicitly set this flag to # true if you want authentication. If authentication is enabled, and no administrative