예제 #1
0
파일: app.go 프로젝트: Chandler/goflesh
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)
}
예제 #2
0
파일: init.go 프로젝트: heaven0sky/yisoso
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)
	}
}
예제 #3
0
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.
	}
}
예제 #4
0
파일: init.go 프로젝트: adarshaj/revel
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)
	})
}
예제 #5
0
파일: init.go 프로젝트: jsli/gorevel
func init() {
	revel.OnAppStart(func() {
		uploadPath = fmt.Sprintf("%s/public/upload/", revel.BasePath)
	})

	revel.InterceptMethod((*Application).inject, revel.BEFORE)
}
예제 #6
0
파일: init.go 프로젝트: pombredanne/goqdb
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)
}
예제 #7
0
파일: init.go 프로젝트: zeuson/gorevel
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
	}
}
예제 #8
0
파일: init.go 프로젝트: argentum47/Fio
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.
	}
}
예제 #9
0
파일: init.go 프로젝트: hura/yield
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)
}
예제 #10
0
파일: plugin.go 프로젝트: huaguzi/revel
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.")
	})
}
예제 #11
0
func init() {
	revel.Filters = []revel.Filter{
		revel.RouterFilter,
		revel.ParamsFilter,
		revel.ActionInvoker,
	}
	revel.OnAppStart(func() {
		runtime.GOMAXPROCS(runtime.NumCPU())
		db.Init()
		qbs.ChangePoolSize(MaxConnectionCount)
	})
}
예제 #12
0
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)
	})
}
예제 #13
0
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)
		}
	})
}
예제 #14
0
파일: init.go 프로젝트: jsli/GoCMS
func init() {

	revel.OnAppStart(func() {
		revel.WARN.Println("开始执行")

		//检测是否登陆
		revel.InterceptMethod(CheckLogin, revel.BEFORE)

		//多核运行
		np := runtime.NumCPU()
		if np >= 2 {
			runtime.GOMAXPROCS(np - 1)
		}
	})
}
예제 #15
0
파일: init.go 프로젝트: river-lee/qishare
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")
	}
}
예제 #16
0
파일: init.go 프로젝트: robfig/acvte
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()
	})
}
예제 #17
0
파일: init.go 프로젝트: huaguzi/revel
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)
	})
}
예제 #18
0
파일: init.go 프로젝트: shaheemirza/CAGo
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
}
예제 #19
0
파일: init.go 프로젝트: netsharec/ironzebra
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)
}
예제 #20
0
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
	})
}
예제 #21
0
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)
		}
	})
}
예제 #22
0
파일: init.go 프로젝트: jsli/ota
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)
	})
}
예제 #23
0
파일: init.go 프로젝트: zeuson/gorevel
func init() {
	revel.OnAppStart(func() {
		jobs.Schedule("cron.update_cache", UpdateCache{})
		jobs.In(5*time.Second, UpdateCache{})
	})
}
예제 #24
0
파일: count.go 프로젝트: kyleconroy/revel
func init() {
	revel.OnAppStart(func() {
		jobs.Schedule("@every 1m", BookingCounter{})
	})
}
예제 #25
0
파일: plugin.go 프로젝트: Qwait/revauth
func init() {
	revel.OnAppStart(func() {
		gorden.AddStrategy("password", controllers.PasswordStrategy{})
		fmt.Println("Revauth Started")
	})
}
예제 #26
0
func init() {
	revel.OnAppStart(Init)
}
예제 #27
0
파일: init.go 프로젝트: uniwolf/gmcadmin
func init() {
	revel.OnAppStart(func() {
		mcServer = revel.Config.StringDefault("memcached", "127.0.0.1:11211")
		mcClient = memcache.New(mcServer)
	})
}
예제 #28
0
파일: plugin.go 프로젝트: robfig/acvte
func init() {
	revel.OnAppStart(func() {
	})
}
예제 #29
0
func init() {
	r.OnAppStart(Init)
}
예제 #30
0
파일: account.go 프로젝트: jsli/cms
func init() {
	revmgo.ControllerInit()
	revel.OnAppStart(revmgo.AppInit)
}