This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/server/redis.js
Tom Moor 83a61b87ed
feat: Normalized server logging (#2567)
* feat: Normalize logging

* Remove scattered console.error + Sentry.captureException

* Remove mention of debug

* cleanup dev output

* Edge cases, docs

* Refactor: Move logger, metrics, sentry under 'logging' folder.
Trying to reduce the amount of things under generic 'utils'

* cleanup, last few console calls
2021-09-14 18:04:35 -07:00

31 lines
944 B
JavaScript

// @flow
import Redis from "ioredis";
import Logger from "./logging/logger";
const options = {
maxRetriesPerRequest: 20,
retryStrategy(times) {
Logger.warn(`Retrying redis connection: attempt ${times}`);
return Math.min(times * 100, 3000);
},
// support Heroku Redis, see:
// https://devcenter.heroku.com/articles/heroku-redis#ioredis-module
tls:
process.env.REDIS_URL && process.env.REDIS_URL.startsWith("rediss://")
? {
rejectUnauthorized: false,
}
: undefined,
};
const client = new Redis(process.env.REDIS_URL, options);
const subscriber = new Redis(process.env.REDIS_URL, options);
// More than the default of 10 listeners is expected for the amount of queues
// we're running. Increase the max here to prevent a warning in the console:
// https://github.com/OptimalBits/bull/issues/1192
client.setMaxListeners(100);
subscriber.setMaxListeners(100);
export { client, subscriber };