feat(core): Add support for floating licenses (#7090)

This PR updates the license-sdk to v2.5.0 which introduces optional
support for floating licenses.
This commit is contained in:
Cornelius Suermann 2023-09-04 15:56:20 +02:00 committed by GitHub
parent fd78021b68
commit e26553f198
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 6 deletions

View file

@ -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",

View file

@ -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;
}

View file

@ -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);

View file

@ -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