Skip to content

Commit 5f19716

Browse files
authored
Merge pull request #431 from STEM-C/fix/redis-tls
Fix/redis tls
2 parents 7d54db0 + 6f4e88d commit 5f19716

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

compile/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"bull": "^3.29.0",
1010
"express": "^4.16.2",
1111
"properties": "^1.2.1",
12+
"redis-url-parse": "^2.0.0",
1213
"throng": "^5.0.0",
1314
"tmp": "0.2.1"
1415
}

compile/src/handlers/worker.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,23 @@ 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+
},
19+
},
20+
}
21+
: REDIS_URL;
922
// The maximum number of jobs each worker should process at once
1023
// Each job is CPU-intensive, so this value should not be too high
1124
const maxJobsPerWorker = process.env.JOB_CONCURRENCY || 1
@@ -22,7 +35,7 @@ module.exports.start = (id) => {
2235
compileLog(`Started worker ${ id }`);
2336

2437
// Connect to the named queue
25-
const compile_queue = new Queue('submissions', REDIS_URL)
38+
const compile_queue = new Queue('submissions', bullOptions)
2639

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

compile/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,11 @@ redis-parser@^3.0.0:
614614
dependencies:
615615
redis-errors "^1.0.0"
616616

617+
redis-url-parse@^2.0.0:
618+
version "2.0.0"
619+
resolved "https://registry.yarnpkg.com/redis-url-parse/-/redis-url-parse-2.0.0.tgz#26807183d2b64252774b6271db3f8d3eb0e12bca"
620+
integrity sha512-ppb4k1YDElELUtmQaltSKouvju/hJATg3i0Lz8qVfdOMkb5AgzjMpJw/AzIybD/KDo0w+3CUef85GbMNPj+k2A==
621+
617622
rimraf@^3.0.0:
618623
version "3.0.2"
619624
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"

0 commit comments

Comments
 (0)