Skip to content

Commit

Permalink
config: bug fix for the config-check mode (pingcap#15190)
Browse files Browse the repository at this point in the history
  • Loading branch information
qw4990 authored Mar 7, 2020
1 parent 5e89ab0 commit 0aef6ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
16 changes: 16 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,22 @@ func InitializeConfig(confPath string, configCheck, configStrict bool, reloadFun
}
}
enforceCmdArgs(cfg)

if err := cfg.Valid(); err != nil {
if !filepath.IsAbs(confPath) {
if tmp, err := filepath.Abs(confPath); err == nil {
confPath = tmp
}
}
fmt.Fprintln(os.Stderr, "load config file:", confPath)
fmt.Fprintln(os.Stderr, "invalid config", err)
os.Exit(1)
}
if configCheck {
fmt.Println("config check successful")
os.Exit(0)
}

globalConfHandler, err = NewConfHandler(confPath, cfg, reloadFunc, nil)
terror.MustNil(err)
globalConfHandler.Start()
Expand Down
15 changes: 0 additions & 15 deletions tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,6 @@ func main() {
registerStores()
registerMetrics()
config.InitializeConfig(*configPath, *configCheck, *configStrict, reloadConfig, overrideConfig)
if err := config.GetGlobalConfig().Valid(); err != nil {
absConfigPath := *configPath
if !filepath.IsAbs(absConfigPath) {
if tmp, err := filepath.Abs(absConfigPath); err == nil {
absConfigPath = tmp
}
}
fmt.Fprintln(os.Stderr, "load config file:", absConfigPath)
fmt.Fprintln(os.Stderr, "invalid config", err)
os.Exit(1)
}
if *configCheck {
fmt.Println("config check successful")
os.Exit(0)
}
setGlobalVars()
setCPUAffinity()
setupLog()
Expand Down

0 comments on commit 0aef6ec

Please sign in to comment.