diff --git a/cmd/supernode/app/root.go b/cmd/supernode/app/root.go index 276e3cfa9..c789bd032 100644 --- a/cmd/supernode/app/root.go +++ b/cmd/supernode/app/root.go @@ -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) @@ -67,17 +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) { if err := setAdvertiseIP(cfg); err != nil {