Push "joinURLs" into config file

Command-line still take precedence.
pull/1376/head
Philip O'Toole 2015-01-26 17:29:30 -08:00
parent d5c0ea396b
commit 3c3792f670
4 changed files with 37 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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