Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(config): reading env vars
Browse files Browse the repository at this point in the history
greenhat616 committed Sep 14, 2023
1 parent 3011ef1 commit c02b17e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions prestart/init_config_driver.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,12 @@ func initConfigDriver() {
logger := logging.GetLogger()
defer logger.Sync()
config.SetDefault()

// Parse env config
viper.SetEnvPrefix("moe") // like: MOE_PORT=8000
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AutomaticEnv()

// Set default viper information
viper.SetConfigName("config")
if config.File != "" {
@@ -54,10 +60,7 @@ func initConfigDriver() {
logger.Warn("[init] No config file detected, reading config from env.")
}
}
// Parse env config
viper.SetEnvPrefix("moe") // like: MOE_PORT=8000
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AutomaticEnv()

logger.Debug("[init] config is parsed.",
zap.String("config_file_used", viper.ConfigFileUsed()),
zap.Any("settings", viper.AllSettings()),

0 comments on commit c02b17e

Please sign in to comment.