diff options
-rw-r--r-- | server/lib/redis.ts | 44 | ||||
-rw-r--r-- | shared/server-commands/server/server.ts | 3 |
2 files changed, 31 insertions, 16 deletions
diff --git a/server/lib/redis.ts b/server/lib/redis.ts index 4dcbcddb5..52766663a 100644 --- a/server/lib/redis.ts +++ b/server/lib/redis.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { createClient } from 'redis' | 1 | import { createClient, RedisClientOptions, RedisModules } from 'redis' |
2 | import { exists } from '@server/helpers/custom-validators/misc' | 2 | import { exists } from '@server/helpers/custom-validators/misc' |
3 | import { sha256 } from '@shared/extra-utils' | 3 | import { sha256 } from '@shared/extra-utils' |
4 | import { logger } from '../helpers/logger' | 4 | import { logger } from '../helpers/logger' |
@@ -37,29 +37,43 @@ class Redis { | |||
37 | 37 | ||
38 | this.client = createClient(Redis.getRedisClientOptions()) | 38 | this.client = createClient(Redis.getRedisClientOptions()) |
39 | 39 | ||
40 | logger.info('Connecting to redis...') | ||
41 | |||
40 | this.client.connect() | 42 | this.client.connect() |
41 | .then(() => { this.connected = true }) | 43 | .then(() => { |
42 | .catch(err => { | 44 | logger.info('Connected to redis.') |
45 | |||
46 | this.connected = true | ||
47 | }).catch(err => { | ||
43 | logger.error('Cannot connect to redis', { err }) | 48 | logger.error('Cannot connect to redis', { err }) |
44 | process.exit(-1) | 49 | process.exit(-1) |
45 | }) | 50 | }) |
46 | 51 | ||
47 | this.client.on('error', err => { | ||
48 | logger.error('Error in Redis client.', { err }) | ||
49 | process.exit(-1) | ||
50 | }) | ||
51 | |||
52 | this.prefix = 'redis-' + WEBSERVER.HOST + '-' | 52 | this.prefix = 'redis-' + WEBSERVER.HOST + '-' |
53 | } | 53 | } |
54 | 54 | ||
55 | static getRedisClientOptions () { | 55 | static getRedisClientOptions () { |
56 | return Object.assign({}, | 56 | let config: RedisClientOptions<RedisModules, {}> = { |
57 | CONFIG.REDIS.AUTH ? { password: CONFIG.REDIS.AUTH } : {}, | 57 | socket: { |
58 | (CONFIG.REDIS.DB) ? { db: CONFIG.REDIS.DB } : {}, | 58 | connectTimeout: 20000 // Could be slow since node use sync call to compile PeerTube |
59 | (CONFIG.REDIS.HOSTNAME && CONFIG.REDIS.PORT) | 59 | } |
60 | ? { host: CONFIG.REDIS.HOSTNAME, port: CONFIG.REDIS.PORT } | 60 | } |
61 | : { path: CONFIG.REDIS.SOCKET } | 61 | |
62 | ) | 62 | if (CONFIG.REDIS.AUTH) { |
63 | config = { ...config, password: CONFIG.REDIS.AUTH } | ||
64 | } | ||
65 | |||
66 | if (CONFIG.REDIS.DB) { | ||
67 | config = { ...config, database: CONFIG.REDIS.DB } | ||
68 | } | ||
69 | |||
70 | if (CONFIG.REDIS.HOSTNAME && CONFIG.REDIS.PORT) { | ||
71 | config.socket = { ...config.socket, host: CONFIG.REDIS.HOSTNAME, port: CONFIG.REDIS.PORT } | ||
72 | } else { | ||
73 | config.socket = { ...config.socket, path: CONFIG.REDIS.SOCKET } | ||
74 | } | ||
75 | |||
76 | return config | ||
63 | } | 77 | } |
64 | 78 | ||
65 | getClient () { | 79 | getClient () { |
diff --git a/shared/server-commands/server/server.ts b/shared/server-commands/server/server.ts index e9201c329..da89fd876 100644 --- a/shared/server-commands/server/server.ts +++ b/shared/server-commands/server/server.ts | |||
@@ -211,7 +211,8 @@ export class PeerTubeServer { | |||
211 | } | 211 | } |
212 | 212 | ||
213 | const execArgv = options.nodeArgs || [] | 213 | const execArgv = options.nodeArgs || [] |
214 | execArgv.push('--enable-source-maps') | 214 | // FIXME: too slow :/ |
215 | // execArgv.push('--enable-source-maps') | ||
215 | 216 | ||
216 | const forkOptions = { | 217 | const forkOptions = { |
217 | silent: true, | 218 | silent: true, |