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

address comments #1

Closed
wants to merge 1 commit 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
7 changes: 6 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/BurntSushi/toml"
"github.com/pingcap/errors"
"github.com/pingcap/tidb/util/logutil"
"github.com/prometheus/common/log"
tracing "github.com/uber/jaeger-client-go/config"
)

Expand Down Expand Up @@ -371,7 +372,7 @@ func GetGlobalConfig() *Config {
}

// Load loads config options from a toml file.
func (c *Config) Load(confFile string) error {
func (c *Config) Load(confFile string, configCheck bool) error {
metaData, err := toml.DecodeFile(confFile, c)
if c.TokenLimit <= 0 {
c.TokenLimit = 1000
Expand All @@ -386,6 +387,10 @@ func (c *Config) Load(confFile string) error {
undecodedItems += fmt.Sprintf(" %s \n", item.String())
}
err = errors.Errorf("config file %s contained unknown configuration options:\n%s", confFile, undecodedItems)
if !configCheck {
log.Warn(err)
err = nil
}
}

return errors.Trace(err)
Expand Down
6 changes: 3 additions & 3 deletions tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func main() {
}
registerStores()
registerMetrics()
loadConfig()
loadConfig(*configCheck)
overrideConfig()
validateConfig()
if *configCheck {
Expand Down Expand Up @@ -291,10 +291,10 @@ func flagBoolean(name string, defaultVal bool, usage string) *bool {
return flag.Bool(name, defaultVal, usage)
}

func loadConfig() {
func loadConfig(configCheck bool) {
cfg = config.GetGlobalConfig()
if *configPath != "" {
err := cfg.Load(*configPath)
err := cfg.Load(*configPath, configCheck)
terror.MustNil(err)
}
}
Expand Down