refactor(core): Couple of refactors on WorkflowRunner and ActiveExecutions (no-changelog) (#8487)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-02-06 18:09:50 +01:00
committed by GitHub
parent dc068ce2e6
commit c04f92f7fd
6 changed files with 66 additions and 143 deletions

View File

@@ -1,6 +1,6 @@
import { Container } from 'typedi';
import { Flags, type Config } from '@oclif/core';
import { ApplicationError, sleep } from 'n8n-workflow';
import { ApplicationError } from 'n8n-workflow';
import config from '@/config';
import { ActiveExecutions } from '@/ActiveExecutions';
@@ -42,21 +42,7 @@ export class Webhook extends BaseCommand {
try {
await this.externalHooks?.run('n8n.stop', []);
// Wait for active workflow executions to finish
const activeExecutionsInstance = Container.get(ActiveExecutions);
let executingWorkflows = activeExecutionsInstance.getActiveExecutions();
let count = 0;
while (executingWorkflows.length !== 0) {
if (count++ % 4 === 0) {
this.logger.info(
`Waiting for ${executingWorkflows.length} active executions to finish...`,
);
}
await sleep(500);
executingWorkflows = activeExecutionsInstance.getActiveExecutions();
}
await Container.get(ActiveExecutions).shutdown();
} catch (error) {
await this.exitWithCrash('There was an error shutting down n8n.', error);
}