Updates to fix against Titan changes and what not.

This commit is contained in:
Travis Reeder
2016-08-07 14:10:31 -04:00
parent bc086a6e05
commit 40e1ebd434
9 changed files with 195 additions and 52 deletions

26
api/config/config.go Normal file
View File

@@ -0,0 +1,26 @@
package config
import (
"fmt"
"os"
"strings"
log "github.com/Sirupsen/logrus"
"github.com/spf13/viper"
)
func InitConfig() {
cwd, _ := os.Getwd()
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.SetDefault("log_level", "info")
viper.SetDefault("db", fmt.Sprintf("bolt://%s/data/bolt.db?bucket=funcs", cwd))
viper.SetConfigName("config")
viper.AddConfigPath(".")
viper.AutomaticEnv() // picks up env vars automatically
viper.ReadInConfig()
logLevel, err := log.ParseLevel(viper.GetString("log_level"))
if err != nil {
log.WithError(err).Fatalln("Invalid log level.")
}
log.SetLevel(logLevel)
}