mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 21:19:43 -08:00
fix(core): Tighten checks for multi-main setup usage (#7788)
https://n8nio.slack.com/archives/C05HRPLSGTT/p1700731476321999?thread_ts=1700729359.746899&cid=C05HRPLSGTT
This commit is contained in:
parent
6208af07eb
commit
fdb2c18ecc
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
import { Service } from 'typedi';
|
import { Service } from 'typedi';
|
||||||
import { ActiveWorkflows, NodeExecuteFunctions } from 'n8n-core';
|
import { ActiveWorkflows, NodeExecuteFunctions } from 'n8n-core';
|
||||||
import config from '@/config';
|
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
ExecutionError,
|
ExecutionError,
|
||||||
|
@ -99,9 +98,7 @@ export class ActiveWorkflowRunner implements IWebhookManager {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
if (config.getEnv('executions.mode') === 'queue' && config.getEnv('multiMainSetup.enabled')) {
|
|
||||||
await this.multiMainSetup.init();
|
await this.multiMainSetup.init();
|
||||||
}
|
|
||||||
|
|
||||||
await this.addActiveWorkflows('init');
|
await this.addActiveWorkflows('init');
|
||||||
|
|
||||||
|
|
|
@ -51,9 +51,7 @@ export class License {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.getEnv('executions.mode') === 'queue' && config.getEnv('multiMainSetup.enabled')) {
|
|
||||||
await this.multiMainSetup.init();
|
await this.multiMainSetup.init();
|
||||||
}
|
|
||||||
|
|
||||||
const isMainInstance = instanceType === 'main';
|
const isMainInstance = instanceType === 'main';
|
||||||
const server = config.getEnv('license.serverUrl');
|
const server = config.getEnv('license.serverUrl');
|
||||||
|
|
|
@ -117,7 +117,7 @@ export class Start extends BaseCommand {
|
||||||
this.pruningService.stopPruning();
|
this.pruningService.stopPruning();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.getEnv('executions.mode') === 'queue' && config.getEnv('multiMainSetup.enabled')) {
|
if (Container.get(MultiMainSetup).isEnabled) {
|
||||||
await this.activeWorkflowRunner.removeAllTriggerAndPollerBasedWorkflows();
|
await this.activeWorkflowRunner.removeAllTriggerAndPollerBasedWorkflows();
|
||||||
|
|
||||||
await Container.get(MultiMainSetup).shutdown();
|
await Container.get(MultiMainSetup).shutdown();
|
||||||
|
|
|
@ -14,6 +14,7 @@ export class MultiMainSetup extends SingleMainSetup {
|
||||||
return (
|
return (
|
||||||
config.getEnv('executions.mode') === 'queue' &&
|
config.getEnv('executions.mode') === 'queue' &&
|
||||||
config.getEnv('multiMainSetup.enabled') &&
|
config.getEnv('multiMainSetup.enabled') &&
|
||||||
|
config.getEnv('generic.instanceType') === 'main' &&
|
||||||
this.isLicensed
|
this.isLicensed
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +38,7 @@ export class MultiMainSetup extends SingleMainSetup {
|
||||||
private leaderCheckInterval: NodeJS.Timer | undefined;
|
private leaderCheckInterval: NodeJS.Timer | undefined;
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
if (this.isInitialized) return;
|
if (!this.isEnabled || this.isInitialized) return;
|
||||||
|
|
||||||
await this.initPublisher();
|
await this.initPublisher();
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ export class PruningService {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
config.getEnv('multiMainSetup.enabled') &&
|
config.getEnv('multiMainSetup.enabled') &&
|
||||||
|
config.getEnv('generic.instanceType') === 'main' &&
|
||||||
config.getEnv('multiMainSetup.instanceType') === 'follower'
|
config.getEnv('multiMainSetup.instanceType') === 'follower'
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -372,7 +372,6 @@ export class WorkflowsService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.getEnv('executions.mode') === 'queue' && config.getEnv('multiMainSetup.enabled')) {
|
|
||||||
const multiMainSetup = Container.get(MultiMainSetup);
|
const multiMainSetup = Container.get(MultiMainSetup);
|
||||||
|
|
||||||
await multiMainSetup.init();
|
await multiMainSetup.init();
|
||||||
|
@ -385,7 +384,6 @@ export class WorkflowsService {
|
||||||
versionId: shared.workflow.versionId,
|
versionId: shared.workflow.versionId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return updatedWorkflow;
|
return updatedWorkflow;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue