mirror of
https://github.com/goharbor/harbor.git
synced 2024-10-02 15:27:42 +02:00
Enable db config cache explicitly
previous config is not cached because it is initialized when cache is not ready Signed-off-by: stonezdj <stonezdj@gmail.com>
This commit is contained in:
parent
b95b3fd84b
commit
162381de56
@ -54,6 +54,7 @@ import (
|
|||||||
"github.com/goharbor/harbor/src/lib/orm"
|
"github.com/goharbor/harbor/src/lib/orm"
|
||||||
tracelib "github.com/goharbor/harbor/src/lib/trace"
|
tracelib "github.com/goharbor/harbor/src/lib/trace"
|
||||||
"github.com/goharbor/harbor/src/migration"
|
"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/config/inmemory"
|
||||||
"github.com/goharbor/harbor/src/pkg/notification"
|
"github.com/goharbor/harbor/src/pkg/notification"
|
||||||
_ "github.com/goharbor/harbor/src/pkg/notifier/topic"
|
_ "github.com/goharbor/harbor/src/pkg/notifier/topic"
|
||||||
@ -176,6 +177,9 @@ func main() {
|
|||||||
if err := cache.Initialize(u.Scheme, redisURL); err != nil {
|
if err := cache.Initialize(u.Scheme, redisURL); err != nil {
|
||||||
log.Fatalf("failed to initialize cache: %v", err)
|
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")
|
beego.AddTemplateExt("htm")
|
||||||
|
|
||||||
|
@ -44,3 +44,12 @@ func NewDBCfgManager() *config.CfgManager {
|
|||||||
manager.LoadSystemConfigFromEnv()
|
manager.LoadSystemConfigFromEnv()
|
||||||
return manager
|
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