username: 'peertube'
password: 'peertube'
+# You can also specify a 'socket' path to a unix socket but first need to
+# comment out hostname and port
redis:
hostname: 'localhost'
port: 6379
password: 'peertube'
# Redis server for short time storage
+# You can also specify a 'socket' path to a unix socket but first need to
+# comment out hostname and port
redis:
hostname: 'localhost'
port: 6379
# If true, a video player will be embedded in the Twitter feed on PeerTube video share
# If false, we use an image link card that will redirect on your PeerTube instance
# Test on https://cards-dev.twitter.com/validator to see if you are whitelisted
- whitelisted: false
\ No newline at end of file
+ whitelisted: false
'webserver.https', 'webserver.hostname', 'webserver.port',
'trust_proxy',
'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password',
- 'redis.hostname', 'redis.port', 'redis.auth', 'redis.db',
'smtp.hostname', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.tls', 'smtp.from_address',
'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache',
'log.level',
'instance.default_nsfw_policy', 'instance.robots',
'services.twitter.username', 'services.twitter.whitelisted'
]
+ const requiredAlternatives = [
+ [ // set
+ ['redis.hostname', 'redis.port'], // alternative
+ ['redis.socket']
+ ]
+ ]
const miss: string[] = []
for (const key of required) {
}
}
+ const missingAlternatives = requiredAlternatives.filter(
+ set => !set.find(alternative => !alternative.find(key => !config.has(key)))
+ )
+
+ missingAlternatives
+ .forEach(set => set[0].forEach(key => miss.push(key)))
+
return miss
}
PASSWORD: config.get<string>('database.password')
},
REDIS: {
- HOSTNAME: config.get<string>('redis.hostname'),
- PORT: config.get<number>('redis.port'),
- AUTH: config.get<string>('redis.auth'),
- DB: config.get<number>('redis.db')
+ HOSTNAME: config.has('redis.hostname') ? config.get<string>('redis.hostname') : null,
+ PORT: config.has('redis.port') ? config.get<number>('redis.port') : null,
+ SOCKET: config.has('redis.socket') ? config.get<string>('redis.socket') : null,
+ AUTH: config.has('redis.auth') ? config.get<string>('redis.auth') : null,
+ DB: config.has('redis.db') ? config.get<number>('redis.db') : null
},
SMTP: {
HOSTNAME: config.get<string>('smtp.hostname'),
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'
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)) {
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 })
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)