mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix(core): Account for waiting jobs during shutdown (#11338)
This commit is contained in:
@@ -126,13 +126,23 @@ export class ScalingService {
|
||||
|
||||
@OnShutdown(HIGHEST_SHUTDOWN_PRIORITY)
|
||||
async stop() {
|
||||
await this.queue.pause(true, true); // no more jobs will be picked up
|
||||
const { instanceType } = this.instanceSettings;
|
||||
|
||||
this.logger.debug('Queue paused');
|
||||
if (instanceType === 'main') await this.stopMain();
|
||||
else if (instanceType === 'worker') await this.stopWorker();
|
||||
}
|
||||
|
||||
this.stopQueueRecovery();
|
||||
this.stopQueueMetrics();
|
||||
private async stopMain() {
|
||||
if (this.orchestrationService.isSingleMainSetup) {
|
||||
await this.queue.pause(true, true); // no more jobs will be picked up
|
||||
this.logger.debug('Queue paused');
|
||||
}
|
||||
|
||||
if (this.queueRecoveryContext.timeout) this.stopQueueRecovery();
|
||||
if (this.isQueueMetricsEnabled) this.stopQueueMetrics();
|
||||
}
|
||||
|
||||
private async stopWorker() {
|
||||
let count = 0;
|
||||
|
||||
while (this.getRunningJobsCount() !== 0) {
|
||||
|
||||
Reference in New Issue
Block a user