diff --git a/packages/cli/package.json b/packages/cli/package.json index d3ba1303f7..7207a938b9 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -102,7 +102,7 @@ }, "dependencies": { "@n8n/client-oauth2": "workspace:*", - "@n8n_io/license-sdk": "~2.4.0", + "@n8n_io/license-sdk": "~2.5.1", "@oclif/command": "^1.8.16", "@oclif/core": "^1.16.4", "@oclif/errors": "^1.3.6", diff --git a/packages/cli/src/License.ts b/packages/cli/src/License.ts index b296c3a333..8b3a62caf5 100644 --- a/packages/cli/src/License.ts +++ b/packages/cli/src/License.ts @@ -104,6 +104,14 @@ export class License { await this.manager.renew(); } + async shutdown() { + if (!this.manager) { + return; + } + + await this.manager.shutdown(); + } + isFeatureEnabled(feature: BooleanLicenseFeature) { return this.manager?.hasFeatureEnabled(feature) ?? false; } diff --git a/packages/cli/src/commands/start.ts b/packages/cli/src/commands/start.ts index 8ae5c16fce..15000ab56a 100644 --- a/packages/cli/src/commands/start.ts +++ b/packages/cli/src/commands/start.ts @@ -28,6 +28,7 @@ import { EDITOR_UI_DIST_DIR, GENERATED_STATIC_DIR } from '@/constants'; import { eventBus } from '@/eventbus'; import { BaseCommand } from './BaseCommand'; import { InternalHooks } from '@/InternalHooks'; +import { License } from '@/License'; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires const open = require('open'); @@ -98,6 +99,10 @@ export class Start extends BaseCommand { await this.exitSuccessFully(); }, 30000); + // Shut down License manager to unclaim any floating entitlements + // Note: While this saves a new license cert to DB, the previous entitlements are still kept in memory so that the shutdown process can complete + await Container.get(License).shutdown(); + await Container.get(InternalHooks).onN8nStop(); const skipWebhookDeregistration = config.getEnv( @@ -133,7 +138,7 @@ export class Start extends BaseCommand { executingWorkflows = activeExecutionsInstance.getActiveExecutions(); } - //finally shut down Event Bus + // Finally shut down Event Bus await eventBus.close(); } catch (error) { await this.exitWithCrash('There was an error shutting down n8n.', error); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 99fa1c4f20..22df3e77bb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -198,8 +198,8 @@ importers: specifier: workspace:* version: link:../@n8n/client-oauth2 '@n8n_io/license-sdk': - specifier: ~2.4.0 - version: 2.4.0 + specifier: ~2.5.1 + version: 2.5.1 '@oclif/command': specifier: ^1.8.16 version: 1.8.18(@oclif/config@1.18.5)(supports-color@8.1.1) @@ -4653,8 +4653,8 @@ packages: acorn-walk: 8.2.0 dev: false - /@n8n_io/license-sdk@2.4.0: - resolution: {integrity: sha512-99kuCVH4NcBi4nyn/WIpd6KSIMLk/pbBks0zr8bC65ALKj0se7/2MwC6N+WwGkG7NqH0kMdGe/7Y5KnJkMTefg==} + /@n8n_io/license-sdk@2.5.1: + resolution: {integrity: sha512-CL4JVJS8nvI8qPFQ1jSG7CiPnNkeKJSgbDxWOLVX4MRjTKrwL8Cpd1LeYMx5g5StmHzkoxz2TDqL8WT6qyMlrQ==} engines: {node: '>=14.0.0', npm: '>=7.10.0'} dependencies: crypto-js: 4.1.1