refactor(core): Create pruning service (no-changelog) (#7564)

https://linear.app/n8n/issue/PAY-954/ensure-only-main-instance-leader-handles-pruning
This commit is contained in:
Iván Ovejero
2023-11-02 12:24:25 +01:00
committed by GitHub
parent be49778388
commit 921d213ae5
6 changed files with 243 additions and 188 deletions

View File

@@ -26,10 +26,10 @@ import { eventBus } from '@/eventbus';
import { BaseCommand } from './BaseCommand';
import { InternalHooks } from '@/InternalHooks';
import { License, FeatureNotLicensedError } from '@/License';
import { ExecutionRepository } from '@/databases/repositories/execution.repository';
import { IConfig } from '@oclif/config';
import { SingleMainInstancePublisher } from '@/services/orchestration/main/SingleMainInstance.publisher';
import { OrchestrationHandlerMainService } from '@/services/orchestration/main/orchestration.handler.main.service';
import { PruningService } from '@/services/pruning.service';
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
const open = require('open');
@@ -110,7 +110,9 @@ export class Start extends BaseCommand {
// 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();
Container.get(ExecutionRepository).clearTimers();
const pruningService = Container.get(PruningService);
if (await pruningService.isPruningEnabled()) await pruningService.stopPruning();
if (config.getEnv('leaderSelection.enabled')) {
const { MultiMainInstancePublisher } = await import(