|
|
@ -33,6 +33,8 @@ export class JobsService implements OnModuleInit { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async add(name: string, data: any) { |
|
|
|
async add(name: string, data: any) { |
|
|
|
|
|
|
|
// if NC_WORKER_CONTAINER is false, then skip dynamic queue pause/resume
|
|
|
|
|
|
|
|
if (process.env.NC_WORKER_CONTAINER !== 'false') { |
|
|
|
// resume primary instance queue if there is no worker
|
|
|
|
// resume primary instance queue if there is no worker
|
|
|
|
const workerCount = await this.jobsRedisService.workerCount(); |
|
|
|
const workerCount = await this.jobsRedisService.workerCount(); |
|
|
|
const localWorkerPaused = await this.jobsQueue.isPaused(true); |
|
|
|
const localWorkerPaused = await this.jobsQueue.isPaused(true); |
|
|
@ -44,6 +46,7 @@ export class JobsService implements OnModuleInit { |
|
|
|
} else if (workerCount > 0 && !localWorkerPaused) { |
|
|
|
} else if (workerCount > 0 && !localWorkerPaused) { |
|
|
|
await this.jobsQueue.pause(true); |
|
|
|
await this.jobsQueue.pause(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const job = await this.jobsQueue.add(name, data); |
|
|
|
const job = await this.jobsQueue.add(name, data); |
|
|
|
|
|
|
|
|
|
|
|