Log ping result if it's not PONG

This commit is contained in:
jvyden 2022-05-15 14:18:00 -04:00
parent bd41997aae
commit f1a0d23c99
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278

View file

@ -1,5 +1,7 @@
#nullable enable #nullable enable
using System; using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
@ -29,6 +31,13 @@ public static class Redis
IRedisConnection connection = getConnection(); IRedisConnection connection = getConnection();
string pong = (await connection.ExecuteAsync("PING")).ToString(CultureInfo.InvariantCulture);
if (pong != "PONG")
{
Logger.LogError("Could not ping, ping returned " + pong, LogArea.Redis);
return;
}
await connection.CreateIndexAsync(typeof(Room)); await connection.CreateIndexAsync(typeof(Room));
await connection.CreateIndexAsync(typeof(UserFriendStore)); await connection.CreateIndexAsync(typeof(UserFriendStore));
@ -38,7 +47,7 @@ public static class Redis
private static IRedisConnection getConnection() private static IRedisConnection getConnection()
{ {
Logger.LogDebug("Getting a redis connection", LogArea.Redis); Logger.LogDebug("Getting a Redis connection", LogArea.Redis);
return provider.Connection; return provider.Connection;
} }