Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
make config file load before init log
Browse files Browse the repository at this point in the history
Signed-off-by: yunfeiyangbuaa <[email protected]>
  • Loading branch information
yunfeiyanggzq committed Oct 22, 2019
1 parent bb999f2 commit 544e1e4
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions cmd/supernode/app/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ var rootCmd = &cobra.Command{
Args: cobra.NoArgs,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
// load config file
if err := readConfigFile(supernodeViper, cmd); err != nil {
return errors.Wrap(err, "read config file")
}

// get config from viper
cfg, err := getConfigFromViper(supernodeViper)
if err != nil {
return errors.Wrap(err, "get config from viper")
}

// create home dir
if err := fileutils.CreateDirectory(supernodeViper.GetString("base.homeDir")); err != nil {
return fmt.Errorf("failed to create home dir %s: %v", supernodeViper.GetString("base.homeDir"), err)
Expand All @@ -67,16 +78,6 @@ var rootCmd = &cobra.Command{
return err
}

// load config file
if err := readConfigFile(supernodeViper, cmd); err != nil {
return errors.Wrap(err, "read config file")
}

// get config from viper
cfg, err := getConfigFromViper(supernodeViper)
if err != nil {
return errors.Wrap(err, "get config from viper")
}

// set supernode advertise ip
if stringutils.IsEmptyStr(cfg.AdvertiseIP) {
Expand Down

0 comments on commit 544e1e4

Please sign in to comment.