diff options
author | Unknown <joe2010xtmf@163.com> | 2014-03-21 10:09:57 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-03-21 10:09:57 -0400 |
commit | d40499e7fa3d62655431f160b6909d9751dabe11 (patch) | |
tree | e02d35f7494e4ba2234de5c0b954553ff9c57709 /modules | |
parent | 67c4e5429818b501b0db5527ea38f2be75e5df55 (diff) | |
download | gitea-d40499e7fa3d62655431f160b6909d9751dabe11.tar.gz gitea-d40499e7fa3d62655431f160b6909d9751dabe11.zip |
Finsih mail resend limit
Diffstat (limited to 'modules')
-rw-r--r-- | modules/base/conf.go | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/modules/base/conf.go b/modules/base/conf.go index 3962972cda..2c3ecd72d8 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -133,6 +133,30 @@ func newLogService() { log.Info("Log Mode: %s(%s)", strings.Title(mode), levelName) } +func newCacheService() { + CacheAdapter = Cfg.MustValue("cache", "ADAPTER", "memory") + + switch CacheAdapter { + case "memory": + CacheConfig = fmt.Sprintf(`{"interval":%d}`, Cfg.MustInt("cache", "INTERVAL", 60)) + case "redis", "memcache": + CacheConfig = fmt.Sprintf(`{"conn":"%s"}`, Cfg.MustValue("cache", "HOST")) + default: + fmt.Printf("Unknown cache adapter: %s\n", CacheAdapter) + os.Exit(2) + } + + var err error + Cache, err = cache.NewCache(CacheAdapter, CacheConfig) + if err != nil { + fmt.Printf("Init cache system failed, adapter: %s, config: %s, %v\n", + CacheAdapter, CacheConfig, err) + os.Exit(2) + } + + log.Info("Cache Service Enabled") +} + func newMailService() { // Check mailer setting. if Cfg.MustBool("mailer", "ENABLED") { @@ -188,16 +212,6 @@ func NewConfigContext() { SecretKey = Cfg.MustValue("security", "SECRET_KEY") RunUser = Cfg.MustValue("", "RUN_USER") - CacheAdapter = Cfg.MustValue("cache", "ADAPTER") - CacheConfig = Cfg.MustValue("cache", "CONFIG") - - Cache, err = cache.NewCache(CacheAdapter, CacheConfig) - if err != nil { - fmt.Printf("Init cache system failed, adapter: %s, config: %s, %v\n", - CacheAdapter, CacheConfig, err) - os.Exit(2) - } - // Determine and create root git reposiroty path. RepoRootPath = Cfg.MustValue("repository", "ROOT") if err = os.MkdirAll(RepoRootPath, os.ModePerm); err != nil { @@ -209,6 +223,7 @@ func NewConfigContext() { func NewServices() { newService() newLogService() + newCacheService() newMailService() newRegisterMailService() } |