mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-05-13 16:07:30 +00:00
fix: assign retention sweep worker deterministically
This commit is contained in:
parent
599e46d004
commit
3529a02c15
1 changed files with 5 additions and 2 deletions
|
|
@ -140,6 +140,7 @@ if (cluster.isMaster) {
|
|||
logger.info(`Spawning ${workers} workers to simulate multi-pod environment`);
|
||||
|
||||
let activeWorkers = 0;
|
||||
const listeningWorkers = new Set();
|
||||
let retentionSweepWorkerId = null;
|
||||
const startTime = Date.now();
|
||||
|
||||
|
|
@ -188,14 +189,16 @@ if (cluster.isMaster) {
|
|||
}
|
||||
});
|
||||
|
||||
cluster.on('listening', () => {
|
||||
if (activeWorkers === workers) {
|
||||
cluster.on('listening', (worker) => {
|
||||
listeningWorkers.add(worker.id);
|
||||
if (listeningWorkers.size === workers) {
|
||||
assignRetentionSweepWorker();
|
||||
}
|
||||
});
|
||||
|
||||
cluster.on('exit', (worker, code, signal) => {
|
||||
activeWorkers--;
|
||||
listeningWorkers.delete(worker.id);
|
||||
if (worker.id === retentionSweepWorkerId) {
|
||||
retentionSweepWorkerId = null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue