fixed up qm tasks and shutdown sequence

This commit is contained in:
Boki 2025-06-21 09:39:09 -04:00
parent 5929612e36
commit 1bb2380a28
4 changed files with 37 additions and 7 deletions

View file

@ -2,6 +2,7 @@ import { getRandomUserAgent } from '@stock-bot/http';
import { getLogger } from '@stock-bot/logger';
import { getMongoDBClient } from '@stock-bot/mongodb-client';
import { QueueManager } from '@stock-bot/queue';
import { isShutdownSignalReceived } from '@stock-bot/shutdown';
import { getRandomProxy } from '@stock-bot/utils';
// Shared instances (module-scoped, not global)
@ -88,7 +89,11 @@ export async function createSessions(): Promise<void> {
);
}
while (sessionCache[sessionId].length < 50) {
while (sessionCache[sessionId].length < 10) {
if(isShutdownSignalReceived()) {
logger.info('Shutting down, skipping session creation');
break; // Exit if shutting down
}
logger.info(`Creating new session for ${sessionId}`);
const proxyInfo = await getRandomProxy();
if (!proxyInfo) {