Load Redis only when Tracking is enabled

This commit is contained in:
Ohpe 2024-04-04 11:53:56 +02:00
parent 255108dc9e
commit 3cf02b5e4c
No known key found for this signature in database
2 changed files with 7 additions and 5 deletions

View file

@ -36,7 +36,7 @@ func (s *Session) InitRedis() error {
// init a new Redis db Pool
RedisPool = newRedisPool()
if _, err := RedisPool.Dial(); err != nil {
return errors.New(fmt.Sprintf("%s %s", tui.Wrap(tui.BACKLIGHTBLUE, tui.Wrap(tui.FOREBLACK, "redis")), err.Error()))
return errors.New(fmt.Sprintf("Error initializing Redis connection: %s %s", tui.Wrap(tui.BACKLIGHTBLUE, tui.Wrap(tui.FOREBLACK, "redis")), err.Error()))
}
return nil

View file

@ -62,10 +62,12 @@ func New() (*Session, error) {
return nil, err
}
// Load Redis
if err = s.InitRedis(); err != nil {
log.Error("%s", err)
return nil, err
// Load Redis only if tracking is enabled
if s.Config.Tracking.Enabled {
if err = s.InitRedis(); err != nil {
log.Error("%s", err)
return nil, err
}
}
log.Info("Connected to Redis")