mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { Container } from '@n8n/di';
|
|
|
|
import { SETTINGS_LICENSE_CERT_KEY } from '@/constants';
|
|
import { SettingsRepository } from '@/databases/repositories/settings.repository';
|
|
import { License } from '@/license';
|
|
|
|
import { BaseCommand } from '../base-command';
|
|
|
|
export class ClearLicenseCommand extends BaseCommand {
|
|
static description = 'Clear license';
|
|
|
|
static examples = ['$ n8n clear:license'];
|
|
|
|
async run() {
|
|
this.logger.info('Clearing license from database.');
|
|
|
|
// Attempt to invoke shutdown() to force any floating entitlements to be released
|
|
const license = Container.get(License);
|
|
await license.init();
|
|
try {
|
|
await license.shutdown();
|
|
} catch {
|
|
this.logger.info('License shutdown failed. Continuing with clearing license from database.');
|
|
}
|
|
|
|
await Container.get(SettingsRepository).delete({
|
|
key: SETTINGS_LICENSE_CERT_KEY,
|
|
});
|
|
this.logger.info('Done. Restart n8n to take effect.');
|
|
}
|
|
|
|
async catch(error: Error) {
|
|
this.logger.error('Error updating database. See log messages for details.');
|
|
this.logger.error('\nGOT ERROR');
|
|
this.logger.info('====================================');
|
|
this.logger.error(error.message);
|
|
this.logger.error(error.stack!);
|
|
}
|
|
}
|