Skip to content

Commit

Permalink
fix: proper handling of uri with transport for our own case
Browse files Browse the repository at this point in the history
  • Loading branch information
linegel committed May 26, 2021
1 parent 64f4564 commit bb9eff2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

const { REDIS_URI } = process.env

let REDIS_URI_WITHOUT_TRANSPORT = '';

if (REDIS_URI.indexOf('redis://') || REDIS_URI.indexOf('rediss://'))
// does "redis://dev-redis:6379" -> "dev-redis:6379"
REDIS_URI_WITHOUT_TRANSPORT = REDIS_URI.split('://')[1];
else
REDIS_URI_WITHOUT_TRANSPORT = REDIS_URI


let Config = {
isInitialized: false,
debug: false,
Expand All @@ -14,8 +23,8 @@ let Config = {
},
passConfigDown: false,
redis: {
port: REDIS_URI ? REDIS_URI.split(':')[1] : 26379,
host: REDIS_URI ? REDIS_URI.split(':')[0] : '127.0.0.1',
host: REDIS_URI ? REDIS_URI_WITHOUT_TRANSPORT.split(':')[0] : '127.0.0.1',
port: REDIS_URI ? REDIS_URI_WITHOUT_TRANSPORT.split(':')[1] : 26379,
},
globalRedisPrefix: '',
retryIntervalMs: 10000,
Expand Down

0 comments on commit bb9eff2

Please sign in to comment.