diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-04-07 11:27:01 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2023-04-07 11:27:01 +0900 |
| commit | 239d3f2dbfb602c20a8bcc89b0be2eeedcc6f3ae (patch) | |
| tree | e81ae7fdb9318a18b2c8794c4bd341ef9d39bf14 /packages/backend | |
| parent | feat(backend): イベント用Redisを別サーバーに分離できるように (diff) | |
| download | sharkey-239d3f2dbfb602c20a8bcc89b0be2eeedcc6f3ae.tar.gz sharkey-239d3f2dbfb602c20a8bcc89b0be2eeedcc6f3ae.tar.bz2 sharkey-239d3f2dbfb602c20a8bcc89b0be2eeedcc6f3ae.zip | |
feat(backend): ジョブキュー用Redisを別サーバーに分離できるように
Diffstat (limited to 'packages/backend')
| -rw-r--r-- | packages/backend/src/config.ts | 11 | ||||
| -rw-r--r-- | packages/backend/src/core/QueueModule.ts | 12 |
2 files changed, 17 insertions, 6 deletions
diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index e8554e5c84..fd2b83cf2a 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -41,6 +41,14 @@ export type Source = { db?: number; prefix?: string; }; + redisForJobQueue?: { + host: string; + port: number; + family?: number; + pass: string; + db?: number; + prefix?: string; + }; elasticsearch: { host: string; port: number; @@ -99,6 +107,8 @@ export type Mixin = { mediaProxy: string; externalMediaProxyEnabled: boolean; videoThumbnailGenerator: string | null; + redisForPubsub: NonNullable<Source['redisForPubsub']>; + redisForJobQueue: NonNullable<Source['redisForJobQueue']>; }; export type Config = Source & Mixin; @@ -160,6 +170,7 @@ export function loadConfig() { if (!config.redis.prefix) config.redis.prefix = mixin.host; if (config.redisForPubsub == null) config.redisForPubsub = config.redis; + if (config.redisForJobQueue == null) config.redisForJobQueue = config.redis; return Object.assign(config, mixin); } diff --git a/packages/backend/src/core/QueueModule.ts b/packages/backend/src/core/QueueModule.ts index edd843977b..8733a7d7eb 100644 --- a/packages/backend/src/core/QueueModule.ts +++ b/packages/backend/src/core/QueueModule.ts @@ -8,13 +8,13 @@ import type { DeliverJobData, InboxJobData, DbJobData, ObjectStorageJobData, End function q<T>(config: Config, name: string, limitPerSec = -1) { return new Bull<T>(name, { redis: { - port: config.redis.port, - host: config.redis.host, - family: config.redis.family == null ? 0 : config.redis.family, - password: config.redis.pass, - db: config.redis.db ?? 0, + port: config.redisForJobQueue.port, + host: config.redisForJobQueue.host, + family: config.redisForJobQueue.family == null ? 0 : config.redisForJobQueue.family, + password: config.redisForJobQueue.pass, + db: config.redisForJobQueue.db ?? 0, }, - prefix: config.redis.prefix ? `${config.redis.prefix}:queue` : 'queue', + prefix: config.redisForJobQueue.prefix ? `${config.redisForJobQueue.prefix}:queue` : 'queue', limiter: limitPerSec > 0 ? { max: limitPerSec, duration: 1000, |