Try to fix tests

This commit is contained in:
Chocobozzz 2022-01-04 09:16:43 +01:00
parent 7298cad6ce
commit 8f5a1f36b5
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 31 additions and 16 deletions

View File

@ -1,4 +1,4 @@
import { createClient } from 'redis' import { createClient, RedisClientOptions, RedisModules } from 'redis'
import { exists } from '@server/helpers/custom-validators/misc' import { exists } from '@server/helpers/custom-validators/misc'
import { sha256 } from '@shared/extra-utils' import { sha256 } from '@shared/extra-utils'
import { logger } from '../helpers/logger' import { logger } from '../helpers/logger'
@ -37,15 +37,15 @@ class Redis {
this.client = createClient(Redis.getRedisClientOptions()) this.client = createClient(Redis.getRedisClientOptions())
this.client.connect() logger.info('Connecting to redis...')
.then(() => { this.connected = true })
.catch(err => {
logger.error('Cannot connect to redis', { err })
process.exit(-1)
})
this.client.on('error', err => { this.client.connect()
logger.error('Error in Redis client.', { err }) .then(() => {
logger.info('Connected to redis.')
this.connected = true
}).catch(err => {
logger.error('Cannot connect to redis', { err })
process.exit(-1) process.exit(-1)
}) })
@ -53,13 +53,27 @@ class Redis {
} }
static getRedisClientOptions () { static getRedisClientOptions () {
return Object.assign({}, let config: RedisClientOptions<RedisModules, {}> = {
CONFIG.REDIS.AUTH ? { password: CONFIG.REDIS.AUTH } : {}, socket: {
(CONFIG.REDIS.DB) ? { db: CONFIG.REDIS.DB } : {}, connectTimeout: 20000 // Could be slow since node use sync call to compile PeerTube
(CONFIG.REDIS.HOSTNAME && CONFIG.REDIS.PORT) }
? { host: CONFIG.REDIS.HOSTNAME, port: CONFIG.REDIS.PORT } }
: { path: CONFIG.REDIS.SOCKET }
) if (CONFIG.REDIS.AUTH) {
config = { ...config, password: CONFIG.REDIS.AUTH }
}
if (CONFIG.REDIS.DB) {
config = { ...config, database: CONFIG.REDIS.DB }
}
if (CONFIG.REDIS.HOSTNAME && CONFIG.REDIS.PORT) {
config.socket = { ...config.socket, host: CONFIG.REDIS.HOSTNAME, port: CONFIG.REDIS.PORT }
} else {
config.socket = { ...config.socket, path: CONFIG.REDIS.SOCKET }
}
return config
} }
getClient () { getClient () {

View File

@ -211,7 +211,8 @@ export class PeerTubeServer {
} }
const execArgv = options.nodeArgs || [] const execArgv = options.nodeArgs || []
execArgv.push('--enable-source-maps') // FIXME: too slow :/
// execArgv.push('--enable-source-maps')
const forkOptions = { const forkOptions = {
silent: true, silent: true,