mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
fix: Initialize license in queue mode correctly (#6301)
This commit is contained in:
parent
55b755cb44
commit
42c79cd6f1
|
@ -98,6 +98,7 @@ export class License {
|
||||||
|
|
||||||
isFeatureEnabled(feature: string): boolean {
|
isFeatureEnabled(feature: string): boolean {
|
||||||
if (!this.manager) {
|
if (!this.manager) {
|
||||||
|
getLogger().warn('License manager not initialized');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials';
|
||||||
import type { IExternalHooksClass } from '@/Interfaces';
|
import type { IExternalHooksClass } from '@/Interfaces';
|
||||||
import { InternalHooks } from '@/InternalHooks';
|
import { InternalHooks } from '@/InternalHooks';
|
||||||
import { PostHogClient } from '@/posthog';
|
import { PostHogClient } from '@/posthog';
|
||||||
|
import { License } from '@/License';
|
||||||
|
|
||||||
export const UM_FIX_INSTRUCTION =
|
export const UM_FIX_INSTRUCTION =
|
||||||
'Please fix the database by running ./packages/cli/bin/n8n user-management:reset';
|
'Please fix the database by running ./packages/cli/bin/n8n user-management:reset';
|
||||||
|
@ -119,6 +120,28 @@ export abstract class BaseCommand extends Command {
|
||||||
await this.externalHooks.init();
|
await this.externalHooks.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async initLicense(): Promise<void> {
|
||||||
|
const license = Container.get(License);
|
||||||
|
await license.init(this.instanceId);
|
||||||
|
|
||||||
|
const activationKey = config.getEnv('license.activationKey');
|
||||||
|
|
||||||
|
if (activationKey) {
|
||||||
|
const hasCert = (await license.loadCertStr()).length > 0;
|
||||||
|
|
||||||
|
if (hasCert) {
|
||||||
|
return LoggerProxy.debug('Skipping license activation');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
LoggerProxy.debug('Attempting license activation');
|
||||||
|
await license.activate(activationKey);
|
||||||
|
} catch (e) {
|
||||||
|
LoggerProxy.error('Could not activate license', e as Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async finally(error: Error | undefined) {
|
async finally(error: Error | undefined) {
|
||||||
if (inTest || this.id === 'start') return;
|
if (inTest || this.id === 'start') return;
|
||||||
if (Db.connectionState.connected) {
|
if (Db.connectionState.connected) {
|
||||||
|
|
|
@ -28,7 +28,6 @@ import { EDITOR_UI_DIST_DIR, GENERATED_STATIC_DIR } from '@/constants';
|
||||||
import { eventBus } from '@/eventbus';
|
import { eventBus } from '@/eventbus';
|
||||||
import { BaseCommand } from './BaseCommand';
|
import { BaseCommand } from './BaseCommand';
|
||||||
import { InternalHooks } from '@/InternalHooks';
|
import { InternalHooks } from '@/InternalHooks';
|
||||||
import { License } from '@/License';
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
|
||||||
const open = require('open');
|
const open = require('open');
|
||||||
|
@ -186,28 +185,6 @@ export class Start extends BaseCommand {
|
||||||
await Promise.all(files.map(compileFile));
|
await Promise.all(files.map(compileFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
async initLicense(): Promise<void> {
|
|
||||||
const license = Container.get(License);
|
|
||||||
await license.init(this.instanceId);
|
|
||||||
|
|
||||||
const activationKey = config.getEnv('license.activationKey');
|
|
||||||
|
|
||||||
if (activationKey) {
|
|
||||||
const hasCert = (await license.loadCertStr()).length > 0;
|
|
||||||
|
|
||||||
if (hasCert) {
|
|
||||||
return LoggerProxy.debug('Skipping license activation');
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
LoggerProxy.debug('Attempting license activation');
|
|
||||||
await license.activate(activationKey);
|
|
||||||
} catch (e) {
|
|
||||||
LoggerProxy.error('Could not activate license', e as Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
await this.initCrashJournal();
|
await this.initCrashJournal();
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,7 @@ export class Webhook extends BaseCommand {
|
||||||
await this.initCrashJournal();
|
await this.initCrashJournal();
|
||||||
await super.init();
|
await super.init();
|
||||||
|
|
||||||
|
await this.initLicense();
|
||||||
await this.initBinaryManager();
|
await this.initBinaryManager();
|
||||||
await this.initExternalHooks();
|
await this.initExternalHooks();
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,6 +224,7 @@ export class Worker extends BaseCommand {
|
||||||
await super.init();
|
await super.init();
|
||||||
this.logger.debug('Starting n8n worker...');
|
this.logger.debug('Starting n8n worker...');
|
||||||
|
|
||||||
|
await this.initLicense();
|
||||||
await this.initBinaryManager();
|
await this.initBinaryManager();
|
||||||
await this.initExternalHooks();
|
await this.initExternalHooks();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue