|
|
|
@ -21,8 +21,13 @@ export class JobsRedis extends PubSubRedis {
|
|
|
|
|
await this.init(); |
|
|
|
|
} |
|
|
|
|
const onMessage = async (channel, message) => { |
|
|
|
|
try { |
|
|
|
|
if (!message || !message.includes(':')) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
const args = message.split(':'); |
|
|
|
|
const command = args.shift(); |
|
|
|
|
|
|
|
|
|
if (channel === InstanceTypes.WORKER) { |
|
|
|
|
this.workerCallbacks[command] && |
|
|
|
|
(await this.workerCallbacks[command](...args)); |
|
|
|
@ -30,6 +35,9 @@ export class JobsRedis extends PubSubRedis {
|
|
|
|
|
this.primaryCallbacks[command] && |
|
|
|
|
(await this.primaryCallbacks[command](...args)); |
|
|
|
|
} |
|
|
|
|
} catch (error) { |
|
|
|
|
this.logger.error('Error processing message' + error); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
if (process.env.NC_WORKER_CONTAINER === 'true') { |
|
|
|
|
await this.subscribe(InstanceTypes.WORKER, async (message) => { |
|
|
|
|