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);
// 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)
this.client.flushdb();
}

5
packages/nocodb/src/main.ts

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

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

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

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

@ -97,14 +97,14 @@ export const JwtStrategyProvider: Provider = {
UsersService,
JwtStrategyProvider,
GlobalGuard,
...(!process.env['NC_WORKER_CONTAINER'] ? [SocketGateway] : []),
...(process.env.NC_WORKER_CONTAINER !== 'true' ? [SocketGateway] : []),
],
exports: [
MetaService,
JwtStrategyProvider,
UsersService,
GlobalGuard,
...(!process.env['NC_WORKER_CONTAINER'] ? [SocketGateway] : []),
...(process.env.NC_WORKER_CONTAINER !== 'true' ? [SocketGateway] : []),
],
})
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,
DatasModule,
MetasModule,
...(process.env['NC_REDIS_URL']
...(process.env.NC_REDIS_URL
? [
BullModule.forRoot({
url: process.env.NC_REDIS_URL,
@ -40,18 +40,18 @@ import { JobsEventService as FallbackJobsEventService } from './fallback/jobs-ev
: []),
],
controllers: [
...(!process.env['NC_WORKER_CONTAINER']
...(process.env.NC_WORKER_CONTAINER !== 'true'
? [DuplicateController, AtImportController]
: []),
],
providers: [
...(!process.env['NC_WORKER_CONTAINER'] ? [JobsGateway] : []),
...(process.env['NC_REDIS_URL']
...(process.env.NC_WORKER_CONTAINER !== 'true' ? [JobsGateway] : []),
...(process.env.NC_REDIS_URL
? [JobsRedisService, JobsEventService]
: [FallbackQueueService, FallbackJobsEventService]),
{
provide: 'JobsService',
useClass: process.env['NC_REDIS_URL'] ? JobsService : FallbackJobsService,
useClass: process.env.NC_REDIS_URL ? JobsService : FallbackJobsService,
},
JobsLogService,
ExportService,

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

@ -19,7 +19,7 @@ export class JobsEventService {
@OnQueueActive()
onActive(job: Job) {
if (process.env['NC_WORKER_CONTAINER']) {
if (process.env.NC_WORKER_CONTAINER === 'true') {
this.jobsRedisService.publish(`jobs-${job.id.toString()}`, {
cmd: JobEvents.STATUS,
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()}`, {
cmd: JobEvents.STATUS,
id: job.id.toString(),
@ -73,7 +73,7 @@ export class JobsEventService {
@OnQueueCompleted()
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()}`, {
cmd: JobEvents.STATUS,
id: job.id.toString(),
@ -96,7 +96,7 @@ export class JobsEventService {
@OnEvent(JobEvents.LOG)
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}`, {
cmd: JobEvents.LOG,
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 } = {};
constructor() {
if (process.env['NC_WORKER_CONTAINER']) {
if (process.env.NC_WORKER_CONTAINER === 'true') {
this.redisClient = new Redis(process.env.NC_REDIS_URL);
return;
}

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

@ -16,7 +16,7 @@ export class JobsService implements OnModuleInit {
// pause primary instance queue
async onModuleInit() {
if (!process.env['NC_WORKER_CONTAINER']) {
if (process.env.NC_WORKER_CONTAINER !== '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,
],
controllers: [
...(!process.env['NC_WORKER_CONTAINER']
...(process.env.NC_WORKER_CONTAINER !== 'true'
? [
ApiDocsController,
ApiTokensController,

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

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

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

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

Loading…
Cancel
Save