Skip to content

Commit 9b6d764

Browse files
authored
fix redis 4 (#449)
1 parent b041484 commit 9b6d764

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

compile/src/handlers/worker.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,24 @@ const { processJob } = require("../controllers/job")
22
const { compileLog } = require("../utils/base")
33

44
const Queue = require("bull")
5+
const redisUrlParse = require("redis-url-parse")
56

67
// Connect to a local redis instance locally, and the Heroku-provided URL in production
78
const REDIS_URL = process.env.REDIS_URL || "redis://compile_queue:6379"
8-
9+
const { host, port, password } = redisUrlParse(REDIS_URL)
10+
const bullOptions = REDIS_URL.includes("rediss://")
11+
? {
12+
redis: {
13+
port: Number(port),
14+
host,
15+
password,
16+
tls: {
17+
rejectUnauthorized: false,
18+
requestCert: true,
19+
},
20+
},
21+
}
22+
: REDIS_URL
923
// The maximum number of jobs each worker should process at once
1024
// Each job is CPU-intensive, so this value should not be too high
1125
const maxJobsPerWorker = process.env.JOB_CONCURRENCY || 1
@@ -20,9 +34,7 @@ module.exports.start = id => {
2034
compileLog(`Started worker ${id}`)
2135

2236
// Connect to the named queue
23-
const compile_queue = new Queue("submissions", REDIS_URL, {
24-
redis: { tls: { rejectUnauthorized: false, requestCert: true } },
25-
})
37+
const compile_queue = new Queue("submissions", bullOptions)
2638

2739
// start processing jobs from the submission queue
2840
compile_queue.process(maxJobsPerWorker, processJob)

0 commit comments

Comments
 (0)