mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
⚡ Wait for active workflow to finish before shutting down
This commit is contained in:
@@ -8,12 +8,14 @@ const open = require('open');
|
|||||||
|
|
||||||
import * as config from '../config';
|
import * as config from '../config';
|
||||||
import {
|
import {
|
||||||
|
ActiveExecutions,
|
||||||
ActiveWorkflowRunner,
|
ActiveWorkflowRunner,
|
||||||
CredentialTypes,
|
CredentialTypes,
|
||||||
CredentialsOverwrites,
|
CredentialsOverwrites,
|
||||||
Db,
|
Db,
|
||||||
ExternalHooks,
|
ExternalHooks,
|
||||||
GenericHelpers,
|
GenericHelpers,
|
||||||
|
IExecutionsCurrentSummary,
|
||||||
LoadNodesAndCredentials,
|
LoadNodesAndCredentials,
|
||||||
NodeTypes,
|
NodeTypes,
|
||||||
Server,
|
Server,
|
||||||
@@ -85,6 +87,21 @@ export class Start extends Command {
|
|||||||
|
|
||||||
await Promise.all(removePromises);
|
await Promise.all(removePromises);
|
||||||
|
|
||||||
|
// Wait for active workflow executions to finish
|
||||||
|
const activeExecutionsInstance = ActiveExecutions.getInstance();
|
||||||
|
let executingWorkflows = activeExecutionsInstance.getActiveExecutions();
|
||||||
|
|
||||||
|
let count = 0;
|
||||||
|
while (executingWorkflows.length !== 0) {
|
||||||
|
if (count++ % 4 === 0) {
|
||||||
|
console.log(`Waiting for ${executingWorkflows.length} active executions to finish...`);
|
||||||
|
}
|
||||||
|
await new Promise((resolve) => {
|
||||||
|
setTimeout(resolve, 500);
|
||||||
|
});
|
||||||
|
executingWorkflows = activeExecutionsInstance.getActiveExecutions();
|
||||||
|
}
|
||||||
|
|
||||||
process.exit(processExistCode);
|
process.exit(processExistCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user