Skip to content

Commit 6ad3307

Browse files
authored
Merge pull request #179 from afrinxnahar/main
move redis to api and worker container, fix worker export issue
2 parents 11e218a + bd112cc commit 6ad3307

File tree

9 files changed

+75
-43
lines changed

9 files changed

+75
-43
lines changed

apps/api/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@tabler/icons-react": "^3.34.1",
3939
"@upstash/redis": "^1.37.0",
4040
"bullmq": "catalog:",
41+
"ioredis": "^5.8.2",
4142
"clsx": "^2.1.1",
4243
"ffmpeg-static": "^5.2.0",
4344
"ffprobe-static": "^3.1.0",

apps/api/src/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Module } from '@nestjs/common';
22
import { ConfigModule } from '@nestjs/config';
33
import { BullModule } from '@nestjs/bullmq';
44
import * as path from 'path';
5-
import { getRedisConnection } from '@repo/config';
5+
import { getRedisConnection } from './redis';
66
import { SupabaseModule } from './supabase/supabase.module';
77

88
import { AppController } from './app.controller';
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@ import Redis from 'ioredis';
22

33
let sharedConnection: Redis | null = null;
44

5-
const defaultUrl = 'redis://127.0.0.1:6379';
6-
75
export function getRedisConnection(): Redis {
86
if (sharedConnection) return sharedConnection;
9-
const url = process.env.REDIS_URL ?? defaultUrl;
10-
sharedConnection = new Redis(url, {
7+
sharedConnection = new Redis(process.env.REDIS_URL ?? 'redis://127.0.0.1:6379', {
118
maxRetriesPerRequest: null,
129
enableReadyCheck: false,
1310
lazyConnect: true,

packages/config/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
"lint": "echo 'No source JavaScript files to lint'",
99
"build": "tsc -p tsconfig.json"
1010
},
11-
"dependencies": {
12-
"ioredis": "^5.8.2"
13-
},
11+
"dependencies": {},
1412
"devDependencies": {
1513
"@repo/typescript-config": "workspace:*",
1614
"eslint": "^9.0.0",

packages/config/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
export * from "./settings/types";
2-
export * from "./redis";
1+
export * from "./settings/types";

packages/train-ai-worker/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
],
99
"exports": {
1010
".": {
11-
"import": "./dist/index.js",
12-
"require": "./dist/index.js"
11+
"import": "./dist/src/index.js",
12+
"require": "./dist/src/index.js"
1313
}
1414
},
1515
"scripts": {
@@ -34,6 +34,7 @@
3434
"@upstash/redis": "^1.37.0",
3535
"axios": "catalog:",
3636
"bullmq": "catalog:",
37+
"ioredis": "^5.8.2",
3738
"jsonrepair": "^3.13.0",
3839
"reflect-metadata": "^0.2.0",
3940
"rxjs": "^7.8.1"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Redis from 'ioredis';
2+
3+
let sharedConnection: Redis | null = null;
4+
5+
export function getRedisConnection(): Redis {
6+
if (sharedConnection) return sharedConnection;
7+
sharedConnection = new Redis(process.env.REDIS_URL ?? 'redis://127.0.0.1:6379', {
8+
maxRetriesPerRequest: null,
9+
enableReadyCheck: false,
10+
lazyConnect: true,
11+
});
12+
return sharedConnection;
13+
}

packages/train-ai-worker/src/worker.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Module } from '@nestjs/common';
22
import { BullModule } from '@nestjs/bullmq';
33
import { ConfigModule } from '@nestjs/config';
44
import * as path from 'path';
5-
import { getRedisConnection } from '@repo/config';
5+
import { getRedisConnection } from './redis';
66
import { HealthController } from './health.controller';
77
import { TrainAiProcessor } from './processor/train-ai.processor';
88
import { ThumbnailProcessor } from './processor/thumbnail.processor';

pnpm-lock.yaml

Lines changed: 53 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)