mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix(core): Fix worker shutdown errors when active executions (#10353)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import Container, { Service } from 'typedi';
|
||||
import { ApplicationError, BINARY_ENCODING } from 'n8n-workflow';
|
||||
import { ApplicationError, BINARY_ENCODING, sleep } from 'n8n-workflow';
|
||||
import { ActiveExecutions } from '@/ActiveExecutions';
|
||||
import config from '@/config';
|
||||
import { Logger } from '@/Logger';
|
||||
@@ -59,10 +59,22 @@ export class ScalingService {
|
||||
}
|
||||
|
||||
@OnShutdown(HIGHEST_SHUTDOWN_PRIORITY)
|
||||
async pauseQueue() {
|
||||
async stop() {
|
||||
await this.queue.pause(true, true);
|
||||
|
||||
this.logger.debug('[ScalingService] Queue paused');
|
||||
|
||||
let count = 0;
|
||||
|
||||
while (this.getRunningJobsCount() !== 0) {
|
||||
if (count++ % 4 === 0) {
|
||||
this.logger.info(
|
||||
`Waiting for ${this.getRunningJobsCount()} active executions to finish...`,
|
||||
);
|
||||
}
|
||||
|
||||
await sleep(500);
|
||||
}
|
||||
}
|
||||
|
||||
async pingQueue() {
|
||||
@@ -113,6 +125,10 @@ export class ScalingService {
|
||||
}
|
||||
}
|
||||
|
||||
getRunningJobsCount() {
|
||||
return this.jobProcessor.getRunningJobIds().length;
|
||||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region Listeners
|
||||
|
||||
Reference in New Issue
Block a user