Explorar o código

Add Redis connection error message

Zed %!s(int64=6) %!d(string=hai) anos
pai
achega
01faa784ea
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  1. 6 2
      src/redis_cache.nim

+ 6 - 2
src/redis_cache.nim

@@ -17,8 +17,12 @@ proc setCacheTimes*(cfg: Config) =
   listCacheTime = cfg.listCacheTime * 60
 
 proc initRedisPool*(cfg: Config) =
-  pool = waitFor newRedisPool(cfg.redisConns, maxConns=cfg.redisMaxConns,
-                              host=cfg.redisHost, port=cfg.redisPort)
+  try:
+    pool = waitFor newRedisPool(cfg.redisConns, maxConns=cfg.redisMaxConns,
+                                host=cfg.redisHost, port=cfg.redisPort)
+  except OSError:
+    echo "Failed to connect to Redis."
+    quit()
 
 template toKey(p: Profile): string = "p:" & toLower(p.username)
 template toKey(v: Video): string = "v:" & v.videoId