40 lines
		
	
	
		
			991 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			991 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package main
 | |
| 
 | |
| import "github.com/spf13/viper"
 | |
| import log "github.com/sirupsen/logrus"
 | |
| 
 | |
| // STEEM_APIURL=https://api.steem.house ./steem-block-db
 | |
| 
 | |
| func main() {
 | |
| 	viper.SetConfigName("steem")
 | |
| 	viper.AddConfigPath("/etc/steem")
 | |
| 	viper.AddConfigPath("$HOME/.config/steem")
 | |
| 	viper.SetEnvPrefix("steem")
 | |
| 	viper.BindEnv("debug")
 | |
| 	viper.BindEnv("redis")
 | |
| 	viper.BindEnv("apiurl")
 | |
| 	err := viper.ReadInConfig() // Find and read the config file if exists
 | |
| 	if err != nil {
 | |
| 		log.Infof("error reading config file: %s \n", err)
 | |
| 	}
 | |
| 	logLevel := log.InfoLevel
 | |
| 	if viper.GetBool("debug") == true {
 | |
| 		logLevel = log.DebugLevel
 | |
| 	}
 | |
| 	redis := "localhost:6379"
 | |
| 	if viper.Get("redis") != nil {
 | |
| 		redis = viper.GetString("redis")
 | |
| 	}
 | |
| 	apiurl := "https://api.steemit.com"
 | |
| 	if viper.Get("apiurl") != nil {
 | |
| 		apiurl = viper.GetString("apiurl")
 | |
| 	}
 | |
| 	app := NewApp(&appconfig{
 | |
| 		logLevel:              logLevel,
 | |
| 		apiUrl:                apiurl,
 | |
| 		redisUrl:              redis,
 | |
| 		desiredFetcherThreads: 40,
 | |
| 	})
 | |
| 	app.main()
 | |
| }
 |