From a75d1b9e9015f737524e5a5c20677d0ebe30d0da Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 7 Nov 2023 06:26:56 +0000 Subject: [PATCH] feat: logging for worker operations --- .../nocodb/src/modules/jobs/redis/jobs.service.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/nocodb/src/modules/jobs/redis/jobs.service.ts b/packages/nocodb/src/modules/jobs/redis/jobs.service.ts index 4202c6f8dc..8dd29c02a4 100644 --- a/packages/nocodb/src/modules/jobs/redis/jobs.service.ts +++ b/packages/nocodb/src/modules/jobs/redis/jobs.service.ts @@ -1,5 +1,5 @@ import { InjectQueue } from '@nestjs/bull'; -import { Injectable } from '@nestjs/common'; +import { Injectable, Logger } from '@nestjs/common'; import { Queue } from 'bull'; import type { OnModuleInit } from '@nestjs/common'; import { JOBS_QUEUE, JobStatus } from '~/interface/Jobs'; @@ -7,6 +7,8 @@ import { JobsRedisService } from '~/modules/jobs/redis/jobs-redis.service'; @Injectable() export class JobsService implements OnModuleInit { + private logger = new Logger(JobsService.name); + constructor( @InjectQueue(JOBS_QUEUE) protected readonly jobsQueue: Queue, protected readonly jobsRedisService: JobsRedisService, @@ -16,20 +18,15 @@ export class JobsService implements OnModuleInit { async onModuleInit() { if (process.env.NC_WORKER_CONTAINER !== 'true') { await this.jobsQueue.pause(true); - this.jobsRedisService.publish('workers', 'pause'); } else { this.jobsRedisService.workerCallbacks['resumeLocal'] = async () => { + this.logger.log('Resuming local queue'); await this.jobsQueue.resume(true); }; this.jobsRedisService.workerCallbacks['pauseLocal'] = async () => { + this.logger.log('Pausing local queue'); await this.jobsQueue.pause(true); }; - this.jobsRedisService.workerCallbacks['resume'] = async () => { - await this.jobsQueue.resume(); - }; - this.jobsRedisService.workerCallbacks['pause'] = async () => { - await this.jobsQueue.pause(); - }; } } @@ -92,10 +89,12 @@ export class JobsService implements OnModuleInit { } async resumeQueue() { + this.logger.log('Resuming global queue'); await this.jobsQueue.resume(); } async pauseQueue() { + this.logger.log('Pausing global queue'); await this.jobsQueue.pause(); } }