File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 9
9
"bull" : " ^3.29.0" ,
10
10
"express" : " ^4.16.2" ,
11
11
"properties" : " ^1.2.1" ,
12
+ "redis-url-parse" : " ^2.0.0" ,
12
13
"throng" : " ^5.0.0" ,
13
14
"tmp" : " 0.2.1"
14
15
}
Original file line number Diff line number Diff line change @@ -2,10 +2,23 @@ const { processJob } = require('../controllers/job')
2
2
const { compileLog } = require ( '../utils/base' )
3
3
4
4
const Queue = require ( 'bull' )
5
+ const redisUrlParse = require ( 'redis-url-parse' )
5
6
6
7
// Connect to a local redis instance locally, and the Heroku-provided URL in production
7
8
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 ;
9
22
// The maximum number of jobs each worker should process at once
10
23
// Each job is CPU-intensive, so this value should not be too high
11
24
const maxJobsPerWorker = process . env . JOB_CONCURRENCY || 1
@@ -22,7 +35,7 @@ module.exports.start = (id) => {
22
35
compileLog ( `Started worker ${ id } ` ) ;
23
36
24
37
// Connect to the named queue
25
- const compile_queue = new Queue ( 'submissions' , REDIS_URL )
38
+ const compile_queue = new Queue ( 'submissions' , bullOptions )
26
39
27
40
// start processing jobs from the submission queue
28
41
compile_queue . process ( maxJobsPerWorker , processJob )
Original file line number Diff line number Diff line change @@ -614,6 +614,11 @@ redis-parser@^3.0.0:
614
614
dependencies :
615
615
redis-errors "^1.0.0"
616
616
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
+
617
622
rimraf@^3.0.0 :
618
623
version "3.0.2"
619
624
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
You can’t perform that action at this time.
0 commit comments