修改数据库连接失败挂起的逻辑为10s后重试

This commit is contained in:
noreply
2024-10-14 20:12:34 +08:00
parent c09886f6da
commit b697409ec0
2 changed files with 19 additions and 6 deletions
+6 -2
View File
@@ -3,11 +3,12 @@ package dao
import (
"context"
"fmt"
"time"
"github.com/assimon/luuu/util/log"
"github.com/go-redis/redis/v8"
"github.com/gookit/color"
"github.com/spf13/viper"
"time"
)
var Rdb *redis.Client
@@ -34,7 +35,10 @@ func RedisInit() {
log.Sugar.Debug("[store_redis] Nil reply returned by Rdb when key does not exist.")
} else if err != nil {
color.Red.Printf("[store_redis] redis connRdb err,err=%s", err)
panic(err)
// panic(err)
time.Sleep(10 * time.Second)
RedisInit()
return
} else {
log.Sugar.Debug("[store_redis] redis connRdb success,suc=%s", pong)
}