1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

adding redis unix connection

This commit is contained in:
Rigel Kent 2018-05-14 17:51:15 +02:00 committed by Rigel Kent
parent 4503cb2a89
commit 19f7b248d8
6 changed files with 36 additions and 17 deletions

View file

@ -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)