func init() { revel.OnAppStart(models.Init) revel.OnAppStart(GorpInit) revel.InterceptMethod((*GorpController).Begin, revel.BEFORE) revel.InterceptMethod((*GorpController).Commit, revel.AFTER) revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY) }
func init() { // Filters is the default set of global filters. revel.OnAppStart(revmgo.AppInit) revel.OnAppStart(AppInit) revel.Filters = []revel.Filter{ revel.PanicFilter, // Recover from panics and display an error page instead. revel.RouterFilter, // Use the routing table to select the right Action revel.FilterConfiguringFilter, // A hook for adding or removing per-Action filters. revel.ParamsFilter, // Parse parameters into Controller.Params. revel.SessionFilter, // Restore and write the session cookie. revel.FlashFilter, // Restore and write the flash cookie. revel.ValidationFilter, // Restore kept validation errors and save new ones from cookie. revel.I18nFilter, // Resolve the requested language revel.InterceptorFilter, // Run interceptors around the action. revel.ActionInvoker, // Invoke the action. } revel.TemplateFuncs["HighLight"] = func(src string, key string) string { res := "" if strings.Contains(src, key) { res = strings.Replace(src, key, "<em>"+key+"</em>", -1) } return res } revel.TemplateFuncs["join"] = func(a []string, sep string) string { return strings.Join(a, sep) } }
func init() { revel.OnAppStart(func() { // Fix don't run on weekends thumbnailServerUrl, _ := revel.Config.String("thumbnail_server") directory, _ := revel.Config.String("root_dir") revel.ERROR.Printf("The directory is %s", directory) jobs.Schedule("@midnight", photoJobs.GenerateThumbnails{Server: thumbnailServerUrl, Directory: directory, Duration: 10800}) }) // Filters is the default set of global filters. revel.Filters = []revel.Filter{ revel.PanicFilter, // Recover from panics and display an error page instead. revel.RouterFilter, // Use the routing table to select the right Action revel.FilterConfiguringFilter, // A hook for adding or removing per-Action filters. revel.ParamsFilter, // Parse parameters into Controller.Params. revel.SessionFilter, // Restore and write the session cookie. revel.FlashFilter, // Restore and write the flash cookie. revel.ValidationFilter, // Restore kept validation errors and save new ones from cookie. revel.I18nFilter, // Resolve the requested language revel.InterceptorFilter, // Run interceptors around the action. revel.ActionInvoker, // Invoke the action. } }
func init() { revel.OnAppStart(func() { // Set the default expiration time. defaultExpiration := time.Hour // The default for the default is one hour. if expireStr, found := revel.Config.String("cache.expires"); found { var err error if defaultExpiration, err = time.ParseDuration(expireStr); err != nil { panic("Could not parse default cache expiration duration " + expireStr + ": " + err.Error()) } } // Use memcached? if revel.Config.BoolDefault("cache.memcached", false) { hosts := strings.Split(revel.Config.StringDefault("cache.hosts", ""), ",") if len(hosts) == 0 { panic("Memcache enabled but no memcached hosts specified!") } Instance = NewMemcachedCache(hosts, defaultExpiration) return } // By default, use the in-memory cache. Instance = NewInMemoryCache(defaultExpiration) }) }
func init() { revel.OnAppStart(func() { uploadPath = fmt.Sprintf("%s/public/upload/", revel.BasePath) }) revel.InterceptMethod((*Application).inject, revel.BEFORE) }
func init() { revel.OnAppStart(Init) revel.InterceptMethod((*GorpController).Begin, revel.BEFORE) // revel.InterceptMethod(Application.AddUser, revel.BEFORE) // revel.InterceptMethod(Hotels.checkUser, revel.BEFORE) revel.InterceptMethod((*GorpController).Commit, revel.AFTER) revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY) }
func init() { revel.OnAppStart(Init) revel.InterceptMethod((*Application).checkUser, revel.BEFORE) revel.TemplateFuncs["eqis"] = func(i int64, s string) bool { return strconv.FormatInt(i, 10) == s } }
func init() { revel.OnAppStart(AppInit) revel.OnAppStart(revmgo.AppInit) // Filters is the default set of global filters. revel.Filters = []revel.Filter{ revel.PanicFilter, // Recover from panics and display an error page instead. revel.RouterFilter, // Use the routing table to select the right Action revel.FilterConfiguringFilter, // A hook for adding or removing per-Action filters. revel.ParamsFilter, // Parse parameters into Controller.Params. revel.SessionFilter, // Restore and write the session cookie. revel.FlashFilter, // Restore and write the flash cookie. revel.ValidationFilter, // Restore kept validation errors and save new ones from cookie. revel.I18nFilter, // Resolve the requested language revel.InterceptorFilter, // Run interceptors around the action. revel.ActionInvoker, // Invoke the action. } }
func init() { revel.OnAppStart(Init) yield.DefaultLayout["html"] = "application.html" revel.InterceptMethod((*GorpController).Begin, revel.BEFORE) revel.InterceptMethod(Application.AddUser, revel.BEFORE) revel.InterceptMethod(Hotels.checkUser, revel.BEFORE) revel.InterceptMethod((*GorpController).Commit, revel.AFTER) revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY) }
func init() { MainCron = cron.New() revel.OnAppStart(func() { if size := revel.Config.IntDefault("jobs.pool", DEFAULT_JOB_POOL_SIZE); size > 0 { workPermits = make(chan struct{}, size) } selfConcurrent = revel.Config.BoolDefault("jobs.selfconcurrent", false) MainCron.Start() fmt.Println("Go to /@jobs to see job status.") }) }
func init() { revel.Filters = []revel.Filter{ revel.RouterFilter, revel.ParamsFilter, revel.ActionInvoker, } revel.OnAppStart(func() { runtime.GOMAXPROCS(runtime.NumCPU()) db.Init() qbs.ChangePoolSize(MaxConnectionCount) }) }
func init() { revel.Filters = []revel.Filter{ revel.RouterFilter, revel.ParamsFilter, revel.ActionInvoker, } revel.OnAppStart(func() { runtime.GOMAXPROCS(runtime.NumCPU()) db.Init() db.Jet.SetMaxIdleConns(MaxConnectionCount) }) }
func init() { revel.OnAppStart(func() { var err error runtime.GOMAXPROCS(runtime.NumCPU()) db.DbPlugin{}.OnAppStart() db.Db.SetMaxIdleConns(MaxConnectionCount) if worldStatement, err = db.Db.Prepare(WorldSelect); err != nil { revel.ERROR.Fatalln(err) } if fortuneStatement, err = db.Db.Prepare(FortuneSelect); err != nil { revel.ERROR.Fatalln(err) } }) }
func init() { revel.OnAppStart(func() { revel.WARN.Println("开始执行") //检测是否登陆 revel.InterceptMethod(CheckLogin, revel.BEFORE) //多核运行 np := runtime.NumCPU() if np >= 2 { runtime.GOMAXPROCS(np - 1) } }) }
func init() { revel.OnAppStart(Init) revel.InterceptMethod((*Qbs).Begin, revel.BEFORE) revel.InterceptMethod((*Application).inject, revel.BEFORE) revel.InterceptMethod((*Qbs).End, revel.AFTER) //注册模板函数, //不等于 revel.TemplateFuncs["notEq"] = func(a, b interface{}) bool { return a != b } revel.TemplateFuncs["dateFormat"] = func(t time.Time) string { return t.Format("2006-01-02") } }
func init() { revel.OnAppStart(func() { var ( found bool spec []string dialect qbs.Dialect ) if Driver, found = revel.Config.String("db.driver"); !found { revel.ERROR.Fatal("No db.driver found.") } switch strings.ToLower(Driver) { case "mysql": dialect = qbs.NewMysql() case "postgres": dialect = qbs.NewPostgres() case "sqlite3": dialect = qbs.NewSqlite3() } // Start building the spec from available config options if User, found = revel.Config.String("db.user"); found { spec = append(spec, User) if Password, found = revel.Config.String("db.password"); found { spec = append(spec, fmt.Sprintf(":%v", Password)) } spec = append(spec, "@") } if Protocol, found = revel.Config.String("db.protocol"); found { spec = append(spec, Protocol) if Address, found = revel.Config.String("db.address"); found { spec = append(spec, fmt.Sprintf("(%v)", Address)) } } if DbName, found = revel.Config.String("db.dbname"); !found { revel.ERROR.Fatal("No db.dbname found.") } spec = append(spec, fmt.Sprintf("/%v", DbName)) if Params, found = revel.Config.String("db.params"); found { spec = append(spec, fmt.Sprintf("?%v", Params)) } qbs.Register(Driver, strings.Join(spec, ""), DbName, dialect) Db, err = qbs.GetQbs() defer Db.Close() }) }
func init() { revel.OnAppStart(func() { // Set the default expiration time. defaultExpiration := time.Hour // The default for the default is one hour. if expireStr, found := revel.Config.String("cache.expires"); found { var err error if defaultExpiration, err = time.ParseDuration(expireStr); err != nil { panic("Could not parse default cache expiration duration " + expireStr + ": " + err.Error()) } } // make sure you aren't trying to use both memcached and redis if revel.Config.BoolDefault("cache.memcached", false) && revel.Config.BoolDefault("cache.redis", false) { panic("You've configured both memcached and redis, please only include configuration for one cache!") } // Use memcached? if revel.Config.BoolDefault("cache.memcached", false) { hosts := strings.Split(revel.Config.StringDefault("cache.hosts", ""), ",") if len(hosts) == 0 { panic("Memcache enabled but no memcached hosts specified!") } Instance = NewMemcachedCache(hosts, defaultExpiration) return } // Use Redis (share same config as memcached)? if revel.Config.BoolDefault("cache.redis", false) { hosts := strings.Split(revel.Config.StringDefault("cache.hosts", ""), ",") if len(hosts) == 0 { panic("Redis enabled but no Redis hosts specified!") } if len(hosts) > 1 { panic("Redis currently only supports one host!") } password := revel.Config.StringDefault("cache.redis.password", "") Instance = NewRedisCache(hosts[0], password, defaultExpiration) return } // By default, use the in-memory cache. Instance = NewInMemoryCache(defaultExpiration) }) }
func init() { // Seed the random library rand.Seed(time.Now().UTC().UnixNano()) revel.OnAppStart(Init) revel.InterceptMethod((*GorpController).Begin, revel.BEFORE) //revel.InterceptMethod(Application.AddUser, revel.BEFORE) revel.InterceptMethod(App.AddUser, revel.BEFORE) revel.InterceptMethod(App.logEntry, revel.BEFORE) //revel.InterceptMethod(Hotels.checkUser, revel.BEFORE) revel.InterceptMethod((*GorpController).Commit, revel.AFTER) revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY) revel.TemplateFuncs["countryOption"] = getCountryOptions revel.TemplateFuncs["keyOption"] = getKeyOptions revel.TemplateFuncs["keyUsageOption"] = getKeyUsageOptions revel.TemplateFuncs["extKeyUsageOption"] = getExtKeyUsageOptions }
func init() { // Filters is the default set of global filters. revel.Filters = []revel.Filter{ revel.PanicFilter, // Recover from panics and display an error page instead. revel.RouterFilter, // Use the routing table to select the right Action revel.FilterConfiguringFilter, // A hook for adding or removing per-Action filters. revel.ParamsFilter, // Parse parameters into Controller.Params. revel.SessionFilter, // Restore and write the session cookie. revel.FlashFilter, // Restore and write the flash cookie. revel.ValidationFilter, // Restore kept validation errors and save new ones from cookie. revel.I18nFilter, // Resolve the requested language revel.InterceptorFilter, // Run interceptors around the action. revel.ActionInvoker, // Invoke the action. } // date formatting revel.TemplateFuncs["formatDate"] = func(date time.Time) string { return date.Format("02 January 2006") } // load the database revel.OnAppStart(revmgo.AppInit) }
func init() { revel.OnAppStart(func() { // Put PanicJsonFilter right after the panic filter // Or put it right before the ActionInvoker. var index int = -1 for i, f := range revel.Filters { if revel.FilterEq(f, revel.PanicFilter) { index = i + 1 } else if revel.FilterEq(f, revel.ActionInvoker) { index = i } } if index == -1 { return } revel.Filters = append(revel.Filters, PanicJsonFilter) copy(revel.Filters[index+1:], revel.Filters[index:]) revel.Filters[index] = PanicJsonFilter }) }
func init() { revel.Filters = []revel.Filter{ revel.RouterFilter, revel.ParamsFilter, revel.ActionInvoker, } revel.OnAppStart(func() { var err error runtime.GOMAXPROCS(runtime.NumCPU()) db.Init() db.Db.SetMaxIdleConns(MaxConnectionCount) if worldStatement, err = db.Db.Prepare(WorldSelect); err != nil { revel.ERROR.Fatalln(err) } if fortuneStatement, err = db.Db.Prepare(FortuneSelect); err != nil { revel.ERROR.Fatalln(err) } if updateStatement, err = db.Db.Prepare(WorldUpdate); err != nil { revel.ERROR.Fatalln(err) } }) }
func init() { // Filters is the default set of global filters. revel.Filters = []revel.Filter{ revel.PanicFilter, // Recover from panics and display an error page instead. revel.RouterFilter, // Use the routing table to select the right Action revel.FilterConfiguringFilter, // A hook for adding or removing per-Action filters. revel.ParamsFilter, // Parse parameters into Controller.Params. revel.SessionFilter, // Restore and write the session cookie. revel.FlashFilter, // Restore and write the flash cookie. revel.ValidationFilter, // Restore kept validation errors and save new ones from cookie. revel.I18nFilter, // Resolve the requested language revel.InterceptorFilter, // Run interceptors around the action. revel.ActionInvoker, // Invoke the action. } revel.OnAppStart(func() { createion_job := ota_job.ReleaseCreationJob{} jobs.Schedule("@every 15s", &createion_job) remove_job := ota_job.ReleaseRemoveJob{} jobs.Schedule("@every 60s", &remove_job) }) }
func init() { revel.OnAppStart(func() { jobs.Schedule("cron.update_cache", UpdateCache{}) jobs.In(5*time.Second, UpdateCache{}) }) }
func init() { revel.OnAppStart(func() { jobs.Schedule("@every 1m", BookingCounter{}) }) }
func init() { revel.OnAppStart(func() { gorden.AddStrategy("password", controllers.PasswordStrategy{}) fmt.Println("Revauth Started") }) }
func init() { revel.OnAppStart(Init) }
func init() { revel.OnAppStart(func() { mcServer = revel.Config.StringDefault("memcached", "127.0.0.1:11211") mcClient = memcache.New(mcServer) }) }
func init() { revel.OnAppStart(func() { }) }
func init() { r.OnAppStart(Init) }
func init() { revmgo.ControllerInit() revel.OnAppStart(revmgo.AppInit) }