"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const executor_service_1 = require("./executor/executor.service");
const logger_1 = require("./utils/logger");
require("./sentry");
const prometheus_1 = require("./prometheus");
let executor;
async function shutdownHandler(executor) {
    if (executor.isShutdownInProgress()) {
        logger_1.logger.info('🚫 Shutdown is already in progress...');
        return;
    }
    await executor.triggerShutdown();
    logger_1.logger.info('Shut-down sequence complete. Bye bye 👋');
    process.exit(0);
}
async function main() {
    const config = (await Promise.resolve().then(() => __importStar(require(`./config/config`)))).default;
    const prometheus = new prometheus_1.Prometheus(config, config.prometheus.port);
    logger_1.logger.info({ enabledNetworks: config.executor.enabledNetworks, enabledAssets: config.executor.enabledAssets }, '🚀 Starting Executor');
    logger_1.logger.info(`💿 Version: ${config.version}`);
    executor = new executor_service_1.Executor(config, prometheus);
    await executor.init();
    executor.start();
}
process.on('SIGINT', async () => {
    logger_1.logger.warn('Received SIGINT signal. Shutting down...');
    await shutdownHandler(executor);
});
process.on('SIGTERM', async () => {
    logger_1.logger.warn('Received SIGTERM signal. Shutting down...');
    await shutdownHandler(executor);
});
void main();
//# sourceMappingURL=executor.js.map