func init() { c := config.Get() l := c.GetInt("log.level") Log = log.New() Log.Out = os.Stderr Log.Level = log.Level(l) }
func main() { logger.Log.Info("Loading Quarid...") c := config.Get() r := http.Router( gin.Logger(), gin.Recovery(), ) r.Run(c.GetString("listen")) }
func init() { c := config.Get() env := c.GetString("env") if env == "" { env = os.Getenv("GIN_MODE") } if env != "" { gin.SetMode(env) } }
func main() { c := config.Get() logger.Log.Info("Loading IRC bot...") q := bot.New(&c) if err := q.Connect(); err != nil { logger.Log.Errorf("%s", err) os.Exit(-1) } defer func() { q.Disconnect() }() }
// GetCrate returns a database for the given Crate func GetCrate(c *crate.Crate) VMDatabase { cfg := config.Get() dbConfig := cfg.GetString("vm.database") uri := strings.Split(dbConfig, "://") // uri[0] is proto, uri[1] is uri uri[1] = fmt.Sprintf("%s/%s", uri, c.ID) d, err := openBolt(uri[0]) if err != nil { l.Errorf("Cannot open VM database %s", uri) return VMDatabase{nil} } return d }
// Get returns the configured, opened database, based on the current // configuration func Get() Database { c := config.Get() dbConfig := c.Get("database") uri, isString := dbConfig.(string) if !isString { if conurl, ok := dbConfig.(db.ConnectionURL); !ok { panic("Cannot connect to database") } else { uri = conurl.String() } } d, err := openPostgresql(uri) if err != nil { l.Errorf("Cannot open database %s: %s", uri, err) return Database{nil} } return d }