"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const dotenv_1 = __importDefault(require("dotenv")); const logger_1 = require("./lib/logger"); const bulk_tracking_worker_1 = require("./workers/bulk-tracking.worker"); dotenv_1.default.config(); async function startWorker() { try { logger_1.logger.info('🔄 Starting Redirect Intelligence Worker Service...'); const bulkWorker = new bulk_tracking_worker_1.BulkTrackingWorker(); await bulkWorker.start(); logger_1.logger.info('🚀 Worker service started successfully', { environment: process.env.NODE_ENV || 'development', redisHost: process.env.REDIS_HOST || 'localhost', concurrency: process.env.BULK_WORKER_CONCURRENCY || '3', }); setInterval(() => { const health = bulkWorker.getHealthStatus(); logger_1.logger.debug('Worker health check', health); }, 30000); const shutdown = async (signal) => { logger_1.logger.info(`🛑 Received ${signal}, shutting down gracefully...`); try { await bulkWorker.stop(); logger_1.logger.info('✅ Worker shutdown completed'); process.exit(0); } catch (error) { logger_1.logger.error('❌ Error during shutdown:', error); process.exit(1); } }; process.on('SIGTERM', () => shutdown('SIGTERM')); process.on('SIGINT', () => shutdown('SIGINT')); process.on('uncaughtException', (error) => { logger_1.logger.error('💥 Uncaught Exception:', error); process.exit(1); }); process.on('unhandledRejection', (reason, promise) => { logger_1.logger.error('💥 Unhandled Rejection at:', promise, 'reason:', reason); process.exit(1); }); } catch (error) { logger_1.logger.error('❌ Failed to start worker service:', error); process.exit(1); } } startWorker(); //# sourceMappingURL=index.js.map