small log fixes

This commit is contained in:
Boki 2025-06-20 16:53:30 -04:00
parent 62a29259b9
commit afa381e390
4 changed files with 32 additions and 26 deletions

View file

@ -11,8 +11,8 @@ import { getLogger, setLoggerConfig, shutdownLoggers } from '@stock-bot/logger';
import { connectMongoDB } from '@stock-bot/mongodb-client';
import { connectPostgreSQL } from '@stock-bot/postgres-client';
import { QueueManager, type QueueManagerConfig } from '@stock-bot/queue';
import { ProxyManager } from '@stock-bot/utils';
import { Shutdown } from '@stock-bot/shutdown';
import { ProxyManager } from '@stock-bot/utils';
// Local imports
import { exchangeRoutes, healthRoutes, queueRoutes } from './routes';
@ -111,7 +111,7 @@ async function initializeServices() {
},
enableScheduledJobs: true,
};
queueManager = QueueManager.getOrInitialize(queueManagerConfig);
logger.info('Queue system initialized');
@ -127,7 +127,7 @@ async function initializeServices() {
const { initializeProxyProvider } = await import('./providers/proxy.provider');
const { initializeQMProvider } = await import('./providers/qm.provider');
const { initializeWebShareProvider } = await import('./providers/webshare.provider');
initializeExchangeSyncProvider();
initializeIBProvider();
initializeProxyProvider();
@ -139,12 +139,12 @@ async function initializeServices() {
logger.debug('Creating scheduled jobs from registered handlers...');
const { handlerRegistry } = await import('@stock-bot/queue');
const allHandlers = handlerRegistry.getAllHandlers();
let totalScheduledJobs = 0;
for (const [handlerName, config] of allHandlers) {
if (config.scheduledJobs && config.scheduledJobs.length > 0) {
const queue = queueManager.getQueue(handlerName);
for (const scheduledJob of config.scheduledJobs) {
// Include handler and operation info in job data
const jobData = {
@ -152,7 +152,7 @@ async function initializeServices() {
operation: scheduledJob.operation,
...(scheduledJob.payload || {}),
};
// Build job options from scheduled job config
const jobOptions = {
priority: scheduledJob.priority,
@ -161,7 +161,7 @@ async function initializeServices() {
immediately: scheduledJob.immediately,
},
};
await queue.addScheduledJob(
scheduledJob.operation,
jobData,
@ -174,7 +174,7 @@ async function initializeServices() {
operation: scheduledJob.operation,
cronPattern: scheduledJob.cronPattern,
immediately: scheduledJob.immediately,
priority: scheduledJob.priority
priority: scheduledJob.priority,
});
}
}
@ -231,7 +231,7 @@ shutdown.onShutdown(async () => {
try {
const { disconnectMongoDB } = await import('@stock-bot/mongodb-client');
const { disconnectPostgreSQL } = await import('@stock-bot/postgres-client');
await disconnectMongoDB();
await disconnectPostgreSQL();
logger.info('Database connections closed');
@ -243,7 +243,7 @@ shutdown.onShutdown(async () => {
shutdown.onShutdown(async () => {
try {
await shutdownLoggers();
process.stdout.write('Data service loggers shut down\n');
// process.stdout.write('Data service loggers shut down\n');
} catch (error) {
process.stderr.write(`Error shutting down loggers: ${error}\n`);
}