Пример #1
0
func init() {
	c := config.Get()
	l := c.GetInt("log.level")

	Log = log.New()
	Log.Out = os.Stderr
	Log.Level = log.Level(l)
}
Пример #2
0
func main() {
	logger.Log.Info("Loading Quarid...")
	c := config.Get()

	r := http.Router(
		gin.Logger(),
		gin.Recovery(),
	)
	r.Run(c.GetString("listen"))
}
Пример #3
0
func init() {
	c := config.Get()
	env := c.GetString("env")
	if env == "" {
		env = os.Getenv("GIN_MODE")
	}

	if env != "" {
		gin.SetMode(env)
	}
}
Пример #4
0
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()
	}()
}
Пример #5
0
// 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
}
Пример #6
0
// 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
}