func Init() { var err error sessionConfig := fmt.Sprintf(`{"cookieName":"gosessionid","gclifetime":%d,"ProviderConfig":"%s"}`, conf.Int("session", "GC_LIFETIME"), fmt.Sprintf("%s, %d", conf.String("redis", "REDIS_SERVER"), conf.Int("session", "SESSION_LENGTH")), ) sessionManager, err = session.NewManager(conf.String("session", "PROVIDER"), sessionConfig) if err != nil { panic(err) } //go sessionManager.GC() }
func Init() { var ( err error ) Engine, err = xorm.NewEngine(sql.Drivers()[0], conf.String("database", "DSN")) if err != nil { panic(err) } if conf.ENV != "release" { Engine.ShowSQL = true } Engine.SetMaxOpenConns(conf.Int("database", "MAX_CONNECTION", 10)) Engine.SetMaxIdleConns(conf.Int("database", "MAX_IDLE_CONNECTION", 50)) Engine.SetLogger(&logAdapter{}) }