Skip to content

Commit cbef7ef

Browse files
authored
Fix early shutdown logic (#24)
1 parent a9a5235 commit cbef7ef

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

javascript/dist/queue/Worker.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ class Worker extends BaseRunner_1.BaseRunner {
132132
const totalWorkers = await this.client.sMembers(this.key('workers'));
133133
const totalWorkersCount = totalWorkers.length;
134134
console.log("[ci-queue] Total workers count: ", totalWorkersCount);
135-
const stayRunningThreshold = Math.min(Math.floor(totalWorkersCount * 0.6), 1);
135+
// Only keep 20% of workers running
136+
const stayRunningThreshold = Math.max(Math.floor(totalWorkersCount * 0.2), 1);
136137
console.log("[ci-queue] Threshold for early shutdown: ", stayRunningThreshold);
137138
const parallelJob = parseInt(this.config.workerId, 10);
138139
const shouldShutdownEarly = parallelJob > stayRunningThreshold;

javascript/src/queue/Worker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ export class Worker extends BaseRunner {
192192
const totalWorkersCount = totalWorkers.length;
193193
console.log("[ci-queue] Total workers count: ", totalWorkersCount);
194194

195-
const stayRunningThreshold = Math.min(Math.floor(totalWorkersCount * 0.4), 1);
195+
// Only keep 20% of workers running
196+
const stayRunningThreshold = Math.max(Math.floor(totalWorkersCount * 0.2), 1);
196197
console.log("[ci-queue] Threshold for early shutdown: ", stayRunningThreshold);
197198

198199
const parallelJob = parseInt(this.config.workerId, 10);

0 commit comments

Comments
 (0)