mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
adding redis unix connection
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import * as Bull from 'bull'
|
||||
import { JobState, JobType } from '../../../shared/models'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { Redis } from '../redis'
|
||||
import { CONFIG, JOB_ATTEMPTS, JOB_COMPLETED_LIFETIME, JOB_CONCURRENCY, JOB_REQUEST_TTL } from '../../initializers'
|
||||
import { ActivitypubHttpBroadcastPayload, processActivityPubHttpBroadcast } from './handlers/activitypub-http-broadcast'
|
||||
import { ActivitypubHttpFetcherPayload, processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher'
|
||||
@@ -63,12 +64,7 @@ class JobQueue {
|
||||
this.jobRedisPrefix = 'bull-' + CONFIG.WEBSERVER.HOST
|
||||
const queueOptions = {
|
||||
prefix: this.jobRedisPrefix,
|
||||
redis: {
|
||||
host: CONFIG.REDIS.HOSTNAME,
|
||||
port: CONFIG.REDIS.PORT,
|
||||
auth: CONFIG.REDIS.AUTH,
|
||||
db: CONFIG.REDIS.DB
|
||||
}
|
||||
redis: Redis.getRedisClient()
|
||||
}
|
||||
|
||||
for (const handlerName of Object.keys(handlers)) {
|
||||
|
||||
@@ -24,11 +24,7 @@ class Redis {
|
||||
if (this.initialized === true) return
|
||||
this.initialized = true
|
||||
|
||||
this.client = createClient({
|
||||
host: CONFIG.REDIS.HOSTNAME,
|
||||
port: CONFIG.REDIS.PORT,
|
||||
db: CONFIG.REDIS.DB
|
||||
})
|
||||
this.client = createClient(Redis.getRedisClient())
|
||||
|
||||
this.client.on('error', err => {
|
||||
logger.error('Error in Redis client.', { err })
|
||||
@@ -42,6 +38,16 @@ class Redis {
|
||||
this.prefix = 'redis-' + CONFIG.WEBSERVER.HOST + '-'
|
||||
}
|
||||
|
||||
static getRedisClient () {
|
||||
return Object.assign({},
|
||||
(CONFIG.REDIS.AUTH && CONFIG.REDIS.AUTH != null) ? { password: CONFIG.REDIS.AUTH } : {},
|
||||
(CONFIG.REDIS.DB) ? { db: CONFIG.REDIS.DB } : {},
|
||||
(CONFIG.REDIS.HOSTNAME && CONFIG.REDIS.PORT) ?
|
||||
{ host: CONFIG.REDIS.HOSTNAME, port: CONFIG.REDIS.PORT } :
|
||||
{ path: CONFIG.REDIS.SOCKET }
|
||||
)
|
||||
}
|
||||
|
||||
async setResetPasswordVerificationString (userId: number) {
|
||||
const generatedString = await generateRandomString(32)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user