added start worker delay
This commit is contained in:
parent
a0e1593af9
commit
19ecd95346
6 changed files with 92 additions and 7 deletions
|
|
@ -93,7 +93,7 @@ async function initializeServices() {
|
|||
});
|
||||
logger.info('PostgreSQL connected');
|
||||
|
||||
// Initialize queue system
|
||||
// Initialize queue system (with delayed worker start)
|
||||
logger.debug('Initializing queue system...');
|
||||
const queueManagerConfig: QueueManagerConfig = {
|
||||
redis: queueConfig?.redis || {
|
||||
|
|
@ -111,12 +111,13 @@ async function initializeServices() {
|
|||
removeOnComplete: true,
|
||||
removeOnFail: false,
|
||||
},
|
||||
workers: 5,
|
||||
concurrency: 20,
|
||||
workers: 2,
|
||||
concurrency: 1,
|
||||
enableMetrics: true,
|
||||
enableDLQ: true,
|
||||
},
|
||||
enableScheduledJobs: true,
|
||||
delayWorkerStart: true, // Prevent workers from starting until all singletons are ready
|
||||
};
|
||||
|
||||
queueManager = QueueManager.getOrInitialize(queueManagerConfig);
|
||||
|
|
@ -189,6 +190,11 @@ async function initializeServices() {
|
|||
}
|
||||
logger.info('Scheduled jobs created', { totalJobs: totalScheduledJobs });
|
||||
|
||||
// Now that all singletons are initialized and jobs are scheduled, start the workers
|
||||
logger.debug('Starting queue workers...');
|
||||
queueManager.startAllWorkers();
|
||||
logger.info('Queue workers started');
|
||||
|
||||
logger.info('All services initialized successfully');
|
||||
} catch (error) {
|
||||
logger.error('Failed to initialize services', { error });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue