1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 17:59:37 +02:00

Add ability to configure stun servers

This commit is contained in:
Chocobozzz 2024-10-24 10:20:50 +02:00
parent 34957c5a18
commit 70ee15d3aa
No known key found for this signature in database
GPG key ID: 583A612D890159BE
13 changed files with 56 additions and 22 deletions

View file

@ -37,7 +37,7 @@ class Redis {
const redisMode = CONFIG.REDIS.SENTINEL.ENABLED ? 'sentinel' : 'standalone'
logger.info(`Connecting to Redis in "${redisMode}" mode...`, lTags())
this.client = new IoRedis(Redis.getRedisClientOptions('', { enableAutoPipelining: true }))
this.client = new IoRedis(Redis.getRedisClientOptions('', { enableAutoPipelining: true }, true))
this.client.on('error', err => logger.error('Redis failed to connect', { err, ...lTags() }))
this.client.on('connect', () => {
logger.info('Connected to redis.', lTags())
@ -59,15 +59,17 @@ class Redis {
this.prefix = 'redis-' + WEBSERVER.HOST + '-'
}
static getRedisClientOptions (name?: string, options: RedisOptions = {}): RedisOptions {
static getRedisClientOptions (name?: string, options: RedisOptions = {}, logOptions = false): RedisOptions {
const connectionName = [ 'PeerTube', name ].join('')
const connectTimeout = 20000 // Could be slow since node use sync call to compile PeerTube
if (CONFIG.REDIS.SENTINEL.ENABLED) {
logger.info(
`Using sentinel redis options`,
{ sentinels: CONFIG.REDIS.SENTINEL.SENTINELS, name: CONFIG.REDIS.SENTINEL.MASTER_NAME, ...lTags() }
)
if (logOptions) {
logger.info(
`Using sentinel redis options`,
{ sentinels: CONFIG.REDIS.SENTINEL.SENTINELS, name: CONFIG.REDIS.SENTINEL.MASTER_NAME, ...lTags() }
)
}
return {
connectionName,
@ -80,10 +82,12 @@ class Redis {
}
}
logger.info(
`Using standalone redis options`,
{ db: CONFIG.REDIS.DB, host: CONFIG.REDIS.HOSTNAME, port: CONFIG.REDIS.PORT, path: CONFIG.REDIS.SOCKET, ...lTags() }
)
if (logOptions) {
logger.info(
`Using standalone redis options`,
{ db: CONFIG.REDIS.DB, host: CONFIG.REDIS.HOSTNAME, port: CONFIG.REDIS.PORT, path: CONFIG.REDIS.SOCKET, ...lTags() }
)
}
return {
connectionName,