Skip to content

Commit

Permalink
Merge pull request #431 from STEM-C/fix/redis-tls
Browse files Browse the repository at this point in the history
Fix/redis tls
  • Loading branch information
mikelxk authored Aug 30, 2022
2 parents 7d54db0 + 6f4e88d commit 5f19716
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions compile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"bull": "^3.29.0",
"express": "^4.16.2",
"properties": "^1.2.1",
"redis-url-parse": "^2.0.0",
"throng": "^5.0.0",
"tmp": "0.2.1"
}
Expand Down
17 changes: 15 additions & 2 deletions compile/src/handlers/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@ const { processJob } = require('../controllers/job')
const { compileLog } = require('../utils/base')

const Queue = require('bull')
const redisUrlParse = require('redis-url-parse')

// Connect to a local redis instance locally, and the Heroku-provided URL in production
const REDIS_URL = process.env.REDIS_URL || 'redis://compile_queue:6379'

const { host, port, password } = redisUrlParse(REDIS_URL);
const bullOptions = REDIS_URL.includes('rediss://')
? {
redis: {
port: Number(port),
host,
password,
tls: {
rejectUnauthorized: false,
},
},
}
: REDIS_URL;
// The maximum number of jobs each worker should process at once
// Each job is CPU-intensive, so this value should not be too high
const maxJobsPerWorker = process.env.JOB_CONCURRENCY || 1
Expand All @@ -22,7 +35,7 @@ module.exports.start = (id) => {
compileLog(`Started worker ${ id }`);

// Connect to the named queue
const compile_queue = new Queue('submissions', REDIS_URL)
const compile_queue = new Queue('submissions', bullOptions)

// start processing jobs from the submission queue
compile_queue.process(maxJobsPerWorker, processJob)
Expand Down
5 changes: 5 additions & 0 deletions compile/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,11 @@ redis-parser@^3.0.0:
dependencies:
redis-errors "^1.0.0"

redis-url-parse@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/redis-url-parse/-/redis-url-parse-2.0.0.tgz#26807183d2b64252774b6271db3f8d3eb0e12bca"
integrity sha512-ppb4k1YDElELUtmQaltSKouvju/hJATg3i0Lz8qVfdOMkb5AgzjMpJw/AzIybD/KDo0w+3CUef85GbMNPj+k2A==

rimraf@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
Expand Down

0 comments on commit 5f19716

Please sign in to comment.