refactor(core): Ensure only leader handles licensing in multi-main scenario (#7558)

https://linear.app/n8n/issue/PAY-953/ensure-only-main-instance-leader-handles-licensing
This commit is contained in:
Iván Ovejero
2023-11-02 14:16:22 +01:00
committed by GitHub
parent 7dac9ab82c
commit 1c77d6597f
3 changed files with 75 additions and 0 deletions

View File

@@ -113,6 +113,17 @@ export class License {
async onFeatureChange(_features: TFeatures): Promise<void> {
if (config.getEnv('executions.mode') === 'queue') {
if (config.getEnv('leaderSelection.enabled')) {
const { MultiMainInstancePublisher } = await import(
'@/services/orchestration/main/MultiMainInstance.publisher.ee'
);
if (Container.get(MultiMainInstancePublisher).isFollower) {
this.logger.debug('Instance is follower, skipping sending of reloadLicense command...');
return;
}
}
if (!this.redisPublisher) {
this.logger.debug('Initializing Redis publisher for License Service');
this.redisPublisher = await Container.get(RedisService).getPubSubPublisher();