switched to new config and removed old
This commit is contained in:
parent
6b69bcbcaa
commit
269364fbc8
70 changed files with 889 additions and 2978 deletions
|
|
@ -5,14 +5,13 @@
|
|||
// Framework imports
|
||||
import { Hono } from 'hono';
|
||||
import { cors } from 'hono/cors';
|
||||
|
||||
// Library imports
|
||||
import { initializeServiceConfig } from '@stock-bot/config-new';
|
||||
import { initializeServiceConfig } from '@stock-bot/config';
|
||||
import { getLogger, setLoggerConfig, shutdownLoggers } from '@stock-bot/logger';
|
||||
import { createAndConnectMongoDBClient, MongoDBClient } from '@stock-bot/mongodb-client';
|
||||
import { createAndConnectPostgreSQLClient, PostgreSQLClient } from '@stock-bot/postgres-client';
|
||||
import { getQueue, initializeQueueSystem, shutdownAllQueues } from '@stock-bot/queue';
|
||||
import { Shutdown } from '@stock-bot/shutdown';
|
||||
|
||||
// Local imports
|
||||
import { exchangeRoutes, healthRoutes, queueRoutes } from './routes';
|
||||
|
||||
|
|
@ -20,6 +19,7 @@ import { exchangeRoutes, healthRoutes, queueRoutes } from './routes';
|
|||
const config = await initializeServiceConfig();
|
||||
const serviceConfig = config.service;
|
||||
const databaseConfig = config.database;
|
||||
const queueConfig = config.queue;
|
||||
|
||||
// Initialize logger with config
|
||||
const loggingConfig = config.logging;
|
||||
|
|
@ -50,6 +50,7 @@ const PORT = serviceConfig.port;
|
|||
let server: ReturnType<typeof Bun.serve> | null = null;
|
||||
let postgresClient: PostgreSQLClient | null = null;
|
||||
let mongoClient: MongoDBClient | null = null;
|
||||
// Queue system will be initialized globally
|
||||
|
||||
// Initialize shutdown manager
|
||||
const shutdown = Shutdown.getInstance({ timeout: 15000 });
|
||||
|
|
@ -97,6 +98,16 @@ async function initializeServices() {
|
|||
});
|
||||
logger.info('PostgreSQL connected');
|
||||
|
||||
// Initialize queue system
|
||||
logger.info('Initializing queue system...');
|
||||
await initializeQueueSystem({
|
||||
redis: queueConfig.redis,
|
||||
defaultJobOptions: queueConfig.defaultJobOptions,
|
||||
workers: 5,
|
||||
concurrency: 20,
|
||||
});
|
||||
logger.info('Queue system initialized');
|
||||
|
||||
logger.info('All services initialized successfully');
|
||||
} catch (error) {
|
||||
logger.error('Failed to initialize services', { error });
|
||||
|
|
@ -130,6 +141,16 @@ shutdown.onShutdown(async () => {
|
|||
}
|
||||
});
|
||||
|
||||
shutdown.onShutdown(async () => {
|
||||
logger.info('Shutting down queue system...');
|
||||
try {
|
||||
await shutdownAllQueues();
|
||||
logger.info('Queue system shut down');
|
||||
} catch (error) {
|
||||
logger.error('Error shutting down queue system', { error });
|
||||
}
|
||||
});
|
||||
|
||||
shutdown.onShutdown(async () => {
|
||||
logger.info('Disconnecting from databases...');
|
||||
try {
|
||||
|
|
@ -160,4 +181,7 @@ startServer().catch(error => {
|
|||
process.exit(1);
|
||||
});
|
||||
|
||||
logger.info('Data service startup initiated');
|
||||
logger.info('Data service startup initiated');
|
||||
|
||||
// Export queue functions for providers
|
||||
export { getQueue };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue