mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 18:25:56 +01:00
Merge pull request #15949 from stonezdj/21nov4_cache_properties
Enable db config cache explicitly
This commit is contained in:
commit
060341ba4e
@ -54,6 +54,7 @@ import (
|
||||
"github.com/goharbor/harbor/src/lib/orm"
|
||||
tracelib "github.com/goharbor/harbor/src/lib/trace"
|
||||
"github.com/goharbor/harbor/src/migration"
|
||||
dbCfg "github.com/goharbor/harbor/src/pkg/config/db"
|
||||
_ "github.com/goharbor/harbor/src/pkg/config/inmemory"
|
||||
"github.com/goharbor/harbor/src/pkg/notification"
|
||||
_ "github.com/goharbor/harbor/src/pkg/notifier/topic"
|
||||
@ -176,6 +177,9 @@ func main() {
|
||||
if err := cache.Initialize(u.Scheme, redisURL); err != nil {
|
||||
log.Fatalf("failed to initialize cache: %v", err)
|
||||
}
|
||||
// when config/db init function is called, the cache is not ready,
|
||||
// enable config cache explicitly when the cache is ready
|
||||
dbCfg.EnableConfigCache()
|
||||
}
|
||||
beego.AddTemplateExt("htm")
|
||||
|
||||
|
@ -44,3 +44,12 @@ func NewDBCfgManager() *config.CfgManager {
|
||||
manager.LoadSystemConfigFromEnv()
|
||||
return manager
|
||||
}
|
||||
|
||||
// EnableConfigCache ...
|
||||
func EnableConfigCache() {
|
||||
if cache.Default() == nil {
|
||||
log.Error("failed to enable config cache, cache is not ready.")
|
||||
return
|
||||
}
|
||||
libCfg.Register(common.DBCfgManager, NewDBCfgManager())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user