Browse Source

fix: revised env variables for jobs

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/5711/head
mertmit 2 years ago
parent
commit
ce293c5591
  1. 2
      packages/nocodb/src/cache/RedisCacheMgr.ts
  2. 5
      packages/nocodb/src/main.ts
  3. 2
      packages/nocodb/src/modules/datas/datas.module.ts
  4. 4
      packages/nocodb/src/modules/global/global.module.ts
  5. 10
      packages/nocodb/src/modules/jobs/jobs.module.ts
  6. 8
      packages/nocodb/src/modules/jobs/redis/jobs-event.service.ts
  7. 2
      packages/nocodb/src/modules/jobs/redis/jobs-redis.service.ts
  8. 2
      packages/nocodb/src/modules/jobs/redis/jobs.service.ts
  9. 2
      packages/nocodb/src/modules/metas/metas.module.ts
  10. 2
      packages/nocodb/src/modules/test/test.module.ts
  11. 2
      packages/nocodb/src/modules/users/users.module.ts

2
packages/nocodb/src/cache/RedisCacheMgr.ts vendored

@ -14,7 +14,7 @@ export default class RedisCacheMgr extends CacheMgr {
this.client = new Redis(config); this.client = new Redis(config);
// avoid flushing db in worker container // avoid flushing db in worker container
if (!process.env['NC_WORKER_CONTAINER']) { if (process.env.NC_WORKER_CONTAINER !== 'true') {
// flush the existing db with selected key (Default: 0) // flush the existing db with selected key (Default: 0)
this.client.flushdb(); this.client.flushdb();
} }

5
packages/nocodb/src/main.ts

@ -5,7 +5,7 @@ import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
if (!process.env['NC_WORKER_CONTAINER']) { if (process.env.NC_WORKER_CONTAINER !== 'true') {
app.use( app.use(
express.json({ limit: process.env.NC_REQUEST_BODY_SIZE || '50mb' }), express.json({ limit: process.env.NC_REQUEST_BODY_SIZE || '50mb' }),
); );
@ -16,9 +16,10 @@ async function bootstrap() {
); );
await app.listen(8080); await app.listen(8080);
} else { } else {
if (!process.env['NC_REDIS_URL']) { if (!process.env.NC_REDIS_URL) {
throw new Error('NC_REDIS_URL is required'); throw new Error('NC_REDIS_URL is required');
} }
process.env.NC_DISABLE_TELE = 'true';
await app.init(); await app.init();
} }
} }

2
packages/nocodb/src/modules/datas/datas.module.ts

@ -27,7 +27,7 @@ import { PublicDatasService } from '../../services/public-datas.service';
}), }),
], ],
controllers: [ controllers: [
...(!process.env['NC_WORKER_CONTAINER'] ...(process.env.NC_WORKER_CONTAINER !== 'true'
? [ ? [
DatasController, DatasController,
BulkDataAliasController, BulkDataAliasController,

4
packages/nocodb/src/modules/global/global.module.ts

@ -97,14 +97,14 @@ export const JwtStrategyProvider: Provider = {
UsersService, UsersService,
JwtStrategyProvider, JwtStrategyProvider,
GlobalGuard, GlobalGuard,
...(!process.env['NC_WORKER_CONTAINER'] ? [SocketGateway] : []), ...(process.env.NC_WORKER_CONTAINER !== 'true' ? [SocketGateway] : []),
], ],
exports: [ exports: [
MetaService, MetaService,
JwtStrategyProvider, JwtStrategyProvider,
UsersService, UsersService,
GlobalGuard, GlobalGuard,
...(!process.env['NC_WORKER_CONTAINER'] ? [SocketGateway] : []), ...(process.env.NC_WORKER_CONTAINER !== 'true' ? [SocketGateway] : []),
], ],
}) })
export class GlobalModule {} export class GlobalModule {}

10
packages/nocodb/src/modules/jobs/jobs.module.ts

@ -28,7 +28,7 @@ import { JobsEventService as FallbackJobsEventService } from './fallback/jobs-ev
GlobalModule, GlobalModule,
DatasModule, DatasModule,
MetasModule, MetasModule,
...(process.env['NC_REDIS_URL'] ...(process.env.NC_REDIS_URL
? [ ? [
BullModule.forRoot({ BullModule.forRoot({
url: process.env.NC_REDIS_URL, url: process.env.NC_REDIS_URL,
@ -40,18 +40,18 @@ import { JobsEventService as FallbackJobsEventService } from './fallback/jobs-ev
: []), : []),
], ],
controllers: [ controllers: [
...(!process.env['NC_WORKER_CONTAINER'] ...(process.env.NC_WORKER_CONTAINER !== 'true'
? [DuplicateController, AtImportController] ? [DuplicateController, AtImportController]
: []), : []),
], ],
providers: [ providers: [
...(!process.env['NC_WORKER_CONTAINER'] ? [JobsGateway] : []), ...(process.env.NC_WORKER_CONTAINER !== 'true' ? [JobsGateway] : []),
...(process.env['NC_REDIS_URL'] ...(process.env.NC_REDIS_URL
? [JobsRedisService, JobsEventService] ? [JobsRedisService, JobsEventService]
: [FallbackQueueService, FallbackJobsEventService]), : [FallbackQueueService, FallbackJobsEventService]),
{ {
provide: 'JobsService', provide: 'JobsService',
useClass: process.env['NC_REDIS_URL'] ? JobsService : FallbackJobsService, useClass: process.env.NC_REDIS_URL ? JobsService : FallbackJobsService,
}, },
JobsLogService, JobsLogService,
ExportService, ExportService,

8
packages/nocodb/src/modules/jobs/redis/jobs-event.service.ts

@ -19,7 +19,7 @@ export class JobsEventService {
@OnQueueActive() @OnQueueActive()
onActive(job: Job) { onActive(job: Job) {
if (process.env['NC_WORKER_CONTAINER']) { if (process.env.NC_WORKER_CONTAINER === 'true') {
this.jobsRedisService.publish(`jobs-${job.id.toString()}`, { this.jobsRedisService.publish(`jobs-${job.id.toString()}`, {
cmd: JobEvents.STATUS, cmd: JobEvents.STATUS,
id: job.id.toString(), id: job.id.toString(),
@ -46,7 +46,7 @@ export class JobsEventService {
), ),
); );
if (process.env['NC_WORKER_CONTAINER']) { if (process.env.NC_WORKER_CONTAINER === 'true') {
this.jobsRedisService.publish(`jobs-${job.id.toString()}`, { this.jobsRedisService.publish(`jobs-${job.id.toString()}`, {
cmd: JobEvents.STATUS, cmd: JobEvents.STATUS,
id: job.id.toString(), id: job.id.toString(),
@ -73,7 +73,7 @@ export class JobsEventService {
@OnQueueCompleted() @OnQueueCompleted()
onCompleted(job: Job, data: any) { onCompleted(job: Job, data: any) {
if (process.env['NC_WORKER_CONTAINER']) { if (process.env.NC_WORKER_CONTAINER === 'true') {
this.jobsRedisService.publish(`jobs-${job.id.toString()}`, { this.jobsRedisService.publish(`jobs-${job.id.toString()}`, {
cmd: JobEvents.STATUS, cmd: JobEvents.STATUS,
id: job.id.toString(), id: job.id.toString(),
@ -96,7 +96,7 @@ export class JobsEventService {
@OnEvent(JobEvents.LOG) @OnEvent(JobEvents.LOG)
onLog(data: { id: string; data: { message: string } }) { onLog(data: { id: string; data: { message: string } }) {
if (process.env['NC_WORKER_CONTAINER']) { if (process.env.NC_WORKER_CONTAINER === 'true') {
this.jobsRedisService.publish(`jobs-${data.id}`, { this.jobsRedisService.publish(`jobs-${data.id}`, {
cmd: JobEvents.LOG, cmd: JobEvents.LOG,
id: data.id, id: data.id,

2
packages/nocodb/src/modules/jobs/redis/jobs-redis.service.ts

@ -8,7 +8,7 @@ export class JobsRedisService {
private unsubscribeCallbacks: { [key: string]: () => void } = {}; private unsubscribeCallbacks: { [key: string]: () => void } = {};
constructor() { constructor() {
if (process.env['NC_WORKER_CONTAINER']) { if (process.env.NC_WORKER_CONTAINER === 'true') {
this.redisClient = new Redis(process.env.NC_REDIS_URL); this.redisClient = new Redis(process.env.NC_REDIS_URL);
return; return;
} }

2
packages/nocodb/src/modules/jobs/redis/jobs.service.ts

@ -16,7 +16,7 @@ export class JobsService implements OnModuleInit {
// pause primary instance queue // pause primary instance queue
async onModuleInit() { async onModuleInit() {
if (!process.env['NC_WORKER_CONTAINER']) { if (process.env.NC_WORKER_CONTAINER !== 'true') {
await this.jobsQueue.pause(true); await this.jobsQueue.pause(true);
} }
} }

2
packages/nocodb/src/modules/metas/metas.module.ts

@ -82,7 +82,7 @@ import { ProjectUsersService } from '../../services/project-users/project-users.
GlobalModule, GlobalModule,
], ],
controllers: [ controllers: [
...(!process.env['NC_WORKER_CONTAINER'] ...(process.env.NC_WORKER_CONTAINER !== 'true'
? [ ? [
ApiDocsController, ApiDocsController,
ApiTokensController, ApiTokensController,

2
packages/nocodb/src/modules/test/test.module.ts

@ -3,7 +3,7 @@ import { TestController } from '../../controllers/test/test.controller';
@Module({ @Module({
controllers: [ controllers: [
...(!process.env['NC_WORKER_CONTAINER'] ? [TestController] : []), ...(process.env.NC_WORKER_CONTAINER !== 'true' ? [TestController] : []),
], ],
}) })
export class TestModule {} export class TestModule {}

2
packages/nocodb/src/modules/users/users.module.ts

@ -11,7 +11,7 @@ import { UsersController } from '../../controllers/users/users.controller';
@Module({ @Module({
imports: [GlobalModule, PassportModule], imports: [GlobalModule, PassportModule],
controllers: [ controllers: [
...(!process.env['NC_WORKER_CONTAINER'] ? [UsersController] : []), ...(process.env.NC_WORKER_CONTAINER !== 'true' ? [UsersController] : []),
], ],
providers: [UsersService, GoogleStrategyProvider], providers: [UsersService, GoogleStrategyProvider],
exports: [UsersService], exports: [UsersService],

Loading…
Cancel
Save