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

Print config #1969

Merged
merged 3 commits into from
Mar 16, 2015
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
### Bugfixes
- [#1971](https://github.com/influxdb/influxdb/pull/1971): Fix leader id initialization.
- [#1975](https://github.com/influxdb/influxdb/pull/1975): Require `q` parameter for query endpoint.
- [#1969](https://github.com/influxdb/influxdb/pull/1969): Print loaded config.

## v0.9.0-rc12 [2015-03-15]

Expand Down
6 changes: 6 additions & 0 deletions cmd/influxd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"io"
"log"
"net"
"net/url"
Expand Down Expand Up @@ -259,6 +260,11 @@ func (c *Config) ShardGroupPreCreateCheckPeriod() time.Duration {
return DefaultRetentionCreatePeriod
}

// WriteConfigFile writes the config to the specified writer
func (c *Config) Write(w io.Writer) error {
return toml.NewEncoder(w).Encode(c)
}

// Size represents a TOML parseable file size.
// Users can specify size using "m" for megabytes and "g" for gigabytes.
type Size int
Expand Down
20 changes: 20 additions & 0 deletions cmd/influxd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ func main() {
execRun(args)
case "version":
execVersion(args[1:])
case "config":
execConfig(args[1:])
case "help":
execHelp(args[1:])
default:
Expand Down Expand Up @@ -102,6 +104,9 @@ func execRun(args []string) {
log.SetFlags(log.LstdFlags)
writePIDFile(*pidPath)

if configPath != nil {
log.Println("No config provided, using default settings")
}
config := parseConfig(*configPath, *hostname)

// Create a logging writer.
Expand Down Expand Up @@ -140,6 +145,21 @@ func execVersion(args []string) {
log.Print(s)
}

// execConfig parses and prints the current config loaded.
func execConfig(args []string) {
// Parse command flags.
fs := flag.NewFlagSet("", flag.ExitOnError)
var (
configPath = fs.String("config", "", "")
hostname = fs.String("hostname", "", "")
)
fs.Parse(args)

config := parseConfig(*configPath, *hostname)

config.Write(os.Stdout)
}

// execHelp runs the "help" command.
func execHelp(args []string) {
fmt.Println(`
Expand Down
1 change: 0 additions & 1 deletion cmd/influxd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ func writePIDFile(path string) {
// parses the configuration from a given path. Sets overrides as needed.
func parseConfig(path, hostname string) *Config {
if path == "" {
log.Println("No config provided, using default settings")
return NewConfig()
}

Expand Down