forked from chartbrew/chartbrew
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathredisConnection.js
More file actions
49 lines (47 loc) · 1.38 KB
/
Copy pathredisConnection.js
File metadata and controls
49 lines (47 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const getRedisOptions = () => {
if (process.env.NODE_ENV === "production") {
if (!process.env.CB_REDIS_HOST) {
console.error("CB_REDIS_HOST is not set. The charts are not going to update automatically."); // eslint-disable-line no-console
}
return {
host: process.env.CB_REDIS_HOST,
port: process.env.CB_REDIS_PORT,
password: process.env.CB_REDIS_PASSWORD,
db: process.env.CB_REDIS_DB,
tls: process.env.CB_REDIS_CA ? { ca: process.env.CB_REDIS_CA } : undefined,
};
} else {
if (!process.env.CB_REDIS_HOST_DEV) {
console.error("CB_REDIS_HOST_DEV is not set. The charts are not going to update automatically."); // eslint-disable-line no-console
}
return {
host: process.env.CB_REDIS_HOST_DEV,
port: process.env.CB_REDIS_PORT_DEV,
password: process.env.CB_REDIS_PASSWORD_DEV,
db: process.env.CB_REDIS_DB_DEV,
tls: process.env.CB_REDIS_CA_DEV ? { ca: process.env.CB_REDIS_CA_DEV } : undefined,
};
}
};
const getQueueOptions = () => {
return {
connection: getRedisOptions(),
defaultJobOptions: {
attempts: 3,
backoff: {
type: "fixed",
delay: 5000
},
removeOnComplete: true,
removeOnFail: true,
},
settings: {
stalledInterval: 30000,
maxStalledCount: 3,
}
};
};
module.exports = {
getRedisOptions,
getQueueOptions,
};