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
|
|
@ -12,11 +12,13 @@
|
|||
"clean": "rm -rf dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"@stock-bot/config-new": "*",
|
||||
"@stock-bot/cache": "*",
|
||||
"@stock-bot/config": "*",
|
||||
"@stock-bot/logger": "*",
|
||||
"@stock-bot/mongodb-client": "*",
|
||||
"@stock-bot/postgres-client": "*",
|
||||
"@stock-bot/questdb-client": "*",
|
||||
"@stock-bot/queue": "*",
|
||||
"@stock-bot/shutdown": "*",
|
||||
"hono": "^4.0.0"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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 };
|
||||
|
|
|
|||
|
|
@ -16,8 +16,10 @@
|
|||
],
|
||||
"references": [
|
||||
{ "path": "../../libs/types" },
|
||||
{ "path": "../../libs/config-new" },
|
||||
{ "path": "../../libs/config" },
|
||||
{ "path": "../../libs/logger" },
|
||||
{ "path": "../../libs/cache" },
|
||||
{ "path": "../../libs/queue" },
|
||||
{ "path": "../../libs/mongodb-client" },
|
||||
{ "path": "../../libs/postgres-client" },
|
||||
{ "path": "../../libs/questdb-client" },
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@
|
|||
"tasks": {
|
||||
"build": {
|
||||
"dependsOn": [
|
||||
"@stock-bot/config-new#build",
|
||||
"@stock-bot/config#build",
|
||||
"@stock-bot/logger#build",
|
||||
"@stock-bot/cache#build",
|
||||
"@stock-bot/queue#build",
|
||||
"@stock-bot/mongodb-client#build",
|
||||
"@stock-bot/postgres-client#build",
|
||||
"@stock-bot/questdb-client#build",
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
"clean": "rm -rf dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"@stock-bot/config-new": "*",
|
||||
"@stock-bot/config": "*",
|
||||
"@stock-bot/logger": "*",
|
||||
"@stock-bot/mongodb-client": "*",
|
||||
"@stock-bot/postgres-client": "*",
|
||||
|
|
|
|||
|
|
@ -5,19 +5,17 @@
|
|||
// 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 { Shutdown } from '@stock-bot/shutdown';
|
||||
|
||||
// Local imports
|
||||
import { enhancedSyncManager } from './services/enhanced-sync-manager';
|
||||
import { syncManager } from './services/sync-manager';
|
||||
// Local imports
|
||||
import { setMongoDBClient, setPostgreSQLClient } from './clients';
|
||||
import { healthRoutes, syncRoutes, enhancedSyncRoutes, statsRoutes } from './routes';
|
||||
import { enhancedSyncRoutes, healthRoutes, statsRoutes, syncRoutes } from './routes';
|
||||
|
||||
// Initialize configuration with automatic monorepo config inheritance
|
||||
const config = await initializeServiceConfig();
|
||||
|
|
|
|||
|
|
@ -1,22 +1,28 @@
|
|||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
"resolveJsonModule": true,
|
||||
"allowImportingTsExtensions": false,
|
||||
"noEmit": false,
|
||||
"allowSyntheticDefaultImports": true
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "**/*.test.ts"]
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist",
|
||||
"**/*.test.ts",
|
||||
"**/*.spec.ts",
|
||||
"**/test/**",
|
||||
"**/tests/**",
|
||||
"**/__tests__/**"
|
||||
],
|
||||
"references": [
|
||||
{ "path": "../../libs/types" },
|
||||
{ "path": "../../libs/config" },
|
||||
{ "path": "../../libs/logger" },
|
||||
{ "path": "../../libs/cache" },
|
||||
{ "path": "../../libs/queue" },
|
||||
{ "path": "../../libs/mongodb-client" },
|
||||
{ "path": "../../libs/postgres-client" },
|
||||
{ "path": "../../libs/questdb-client" },
|
||||
{ "path": "../../libs/shutdown" }
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
"clean": "rm -rf dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"@stock-bot/config-new": "*",
|
||||
"@stock-bot/config": "*",
|
||||
"@stock-bot/logger": "*",
|
||||
"@stock-bot/mongodb-client": "*",
|
||||
"@stock-bot/postgres-client": "*",
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@
|
|||
*/
|
||||
import { Hono } from 'hono';
|
||||
import { cors } from 'hono/cors';
|
||||
import { initializeServiceConfig } from '@stock-bot/config-new';
|
||||
import { getLogger, shutdownLoggers, setLoggerConfig } from '@stock-bot/logger';
|
||||
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 { Shutdown } from '@stock-bot/shutdown';
|
||||
import { setPostgreSQLClient, setMongoDBClient } from './clients';
|
||||
// Import routes
|
||||
import { exchangeRoutes } from './routes/exchange.routes';
|
||||
import { healthRoutes } from './routes/health.routes';
|
||||
import { setMongoDBClient, setPostgreSQLClient } from './clients';
|
||||
|
||||
// Initialize configuration with automatic monorepo config inheritance
|
||||
const config = await initializeServiceConfig();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue