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