mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 20:30:58 -05:00
Replace janky reconnect method with a reliable one from the package.
This commit is contained in:
parent
d434507b9b
commit
543a84a433
@ -6,7 +6,7 @@ const RedisClient = createClient({
|
|||||||
url: (await TSClient()).redis_uri,
|
url: (await TSClient()).redis_uri,
|
||||||
database: 0,
|
database: 0,
|
||||||
name: 'Daggerbot',
|
name: 'Daggerbot',
|
||||||
socket: { keepAlive: 15000, timeout: 30000 }
|
socket: { keepAlive: 15000, timeout: 30000, reconnectStrategy(retries:number = 5) {return Math.min(retries * 76, 1000)} }
|
||||||
});
|
});
|
||||||
|
|
||||||
export default class CacheServer {
|
export default class CacheServer {
|
||||||
@ -14,16 +14,7 @@ export default class CacheServer {
|
|||||||
protected static eventManager() {
|
protected static eventManager() {
|
||||||
RedisClient
|
RedisClient
|
||||||
.on('connect', ()=>Logger.console('log', this.prefix, 'Connection to Redis has been established'))
|
.on('connect', ()=>Logger.console('log', this.prefix, 'Connection to Redis has been established'))
|
||||||
.on('error', (err:ErrorReply)=>{
|
.on('error', (err:ErrorReply)=>Logger.console('error', this.prefix, `Encountered an error in Redis: ${err.message}`))
|
||||||
Logger.console('error', this.prefix, `Encountered an error in Redis: ${err.message}`)
|
|
||||||
setTimeout(async()=>{
|
|
||||||
if (!RedisClient.isReady) {
|
|
||||||
Logger.console('log', this.prefix, 'Client is zombified, starting a fresh connection...');
|
|
||||||
RedisClient.quit();
|
|
||||||
await RedisClient.connect();
|
|
||||||
}
|
|
||||||
}, 1500)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
public static async get(key:any, jsonMode:boolean):Promise<any> {
|
public static async get(key:any, jsonMode:boolean):Promise<any> {
|
||||||
let cachedResult:any;
|
let cachedResult:any;
|
||||||
|
Loading…
Reference in New Issue
Block a user