Exemple #1
0
func init() {
	err := gas.EnvConf(&Env, gas.EnvPrefix)
	if err != nil {
		log.Fatalf("db (init): %v", err)
	}

	if Env.DBName == "" {
		log.Printf("%sDB_NAME is not set, database support disabled", gas.EnvPrefix)
		return
	}

	if Env.DBParams == "" {
		log.Printf("%sDB_PARAMS is not set, database support disabled", gas.EnvPrefix)
		return
	}

	DB, err = sql.Open(Env.DBName, Env.DBParams)
	if err != nil {
		log.Fatalf("db (init): %v", err)
	}

	gas.AddDestructor(func() {
		for _, stmt := range stmtCache {
			stmt.Close()
		}
		if DB != nil {
			DB.Close()
		}
	})
}
Exemple #2
0
func init() {
	if err := gas.EnvConf(&Env, gas.EnvPrefix); err != nil {
		log.Fatalf("auth (init): %v", err)
	}

	if len(Env.CookieAuthKey) > 0 {
		hmacKeys = bytes.Split(Env.CookieAuthKey, []byte{byte(os.PathListSeparator)})
	}

}