diff options
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/job-queue/job-queue.ts | 8 | ||||
-rw-r--r-- | server/lib/redis.ts | 16 |
2 files changed, 13 insertions, 11 deletions
diff --git a/server/lib/job-queue/job-queue.ts b/server/lib/job-queue/job-queue.ts index 77aaa7fa8..1b46180e8 100644 --- a/server/lib/job-queue/job-queue.ts +++ b/server/lib/job-queue/job-queue.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import * as Bull from 'bull' | 1 | import * as Bull from 'bull' |
2 | import { JobState, JobType } from '../../../shared/models' | 2 | import { JobState, JobType } from '../../../shared/models' |
3 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
4 | import { Redis } from '../redis' | ||
4 | import { CONFIG, JOB_ATTEMPTS, JOB_COMPLETED_LIFETIME, JOB_CONCURRENCY, JOB_REQUEST_TTL } from '../../initializers' | 5 | import { CONFIG, JOB_ATTEMPTS, JOB_COMPLETED_LIFETIME, JOB_CONCURRENCY, JOB_REQUEST_TTL } from '../../initializers' |
5 | import { ActivitypubHttpBroadcastPayload, processActivityPubHttpBroadcast } from './handlers/activitypub-http-broadcast' | 6 | import { ActivitypubHttpBroadcastPayload, processActivityPubHttpBroadcast } from './handlers/activitypub-http-broadcast' |
6 | import { ActivitypubHttpFetcherPayload, processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher' | 7 | import { ActivitypubHttpFetcherPayload, processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher' |
@@ -63,12 +64,7 @@ class JobQueue { | |||
63 | this.jobRedisPrefix = 'bull-' + CONFIG.WEBSERVER.HOST | 64 | this.jobRedisPrefix = 'bull-' + CONFIG.WEBSERVER.HOST |
64 | const queueOptions = { | 65 | const queueOptions = { |
65 | prefix: this.jobRedisPrefix, | 66 | prefix: this.jobRedisPrefix, |
66 | redis: { | 67 | redis: Redis.getRedisClient() |
67 | host: CONFIG.REDIS.HOSTNAME, | ||
68 | port: CONFIG.REDIS.PORT, | ||
69 | auth: CONFIG.REDIS.AUTH, | ||
70 | db: CONFIG.REDIS.DB | ||
71 | } | ||
72 | } | 68 | } |
73 | 69 | ||
74 | for (const handlerName of Object.keys(handlers)) { | 70 | for (const handlerName of Object.keys(handlers)) { |
diff --git a/server/lib/redis.ts b/server/lib/redis.ts index 78b28986a..06a340060 100644 --- a/server/lib/redis.ts +++ b/server/lib/redis.ts | |||
@@ -24,11 +24,7 @@ class Redis { | |||
24 | if (this.initialized === true) return | 24 | if (this.initialized === true) return |
25 | this.initialized = true | 25 | this.initialized = true |
26 | 26 | ||
27 | this.client = createClient({ | 27 | this.client = createClient(Redis.getRedisClient()) |
28 | host: CONFIG.REDIS.HOSTNAME, | ||
29 | port: CONFIG.REDIS.PORT, | ||
30 | db: CONFIG.REDIS.DB | ||
31 | }) | ||
32 | 28 | ||
33 | this.client.on('error', err => { | 29 | this.client.on('error', err => { |
34 | logger.error('Error in Redis client.', { err }) | 30 | logger.error('Error in Redis client.', { err }) |
@@ -42,6 +38,16 @@ class Redis { | |||
42 | this.prefix = 'redis-' + CONFIG.WEBSERVER.HOST + '-' | 38 | this.prefix = 'redis-' + CONFIG.WEBSERVER.HOST + '-' |
43 | } | 39 | } |
44 | 40 | ||
41 | static getRedisClient () { | ||
42 | return Object.assign({}, | ||
43 | (CONFIG.REDIS.AUTH && CONFIG.REDIS.AUTH != null) ? { password: CONFIG.REDIS.AUTH } : {}, | ||
44 | (CONFIG.REDIS.DB) ? { db: CONFIG.REDIS.DB } : {}, | ||
45 | (CONFIG.REDIS.HOSTNAME && CONFIG.REDIS.PORT) ? | ||
46 | { host: CONFIG.REDIS.HOSTNAME, port: CONFIG.REDIS.PORT } : | ||
47 | { path: CONFIG.REDIS.SOCKET } | ||
48 | ) | ||
49 | } | ||
50 | |||
45 | async setResetPasswordVerificationString (userId: number) { | 51 | async setResetPasswordVerificationString (userId: number) { |
46 | const generatedString = await generateRandomString(32) | 52 | const generatedString = await generateRandomString(32) |
47 | 53 | ||