--- name: Livelo apontada pra proxy 40520 (smart-bridge VM ADV-22) 2026-05-02 description: Livelo migrada pro proxy 40520 (VM IP residencial BH) porque saída direta do servidor caiu. Cache 60min + dedup + safety nets validados OW/RT/multipax/business/intl. type: project originSessionId: da5514be-fbd6-46e5-a3de-cf03a5dda20d --- # Livelo via smart-bridge 40520 — 2026-05-02 ## Motivo Servidor 173.208.187.154 perdeu saída direta de internet (DNS systemd-resolved e TCP outbound timeout pra 8.8.8.8/1.1.1.1, ping gateway local OK). Livelo retornava silenciosamente `success:true totalFlights:0` e ainda cacheava por 60min, mascarando o problema. **Why:** Jesiel pediu Livelo estável + cache 60min sem afetar outras companhias (deploy_isolation). ## Mudanças (somente Livelo) `/opt/skymilhas/scrapers/livelo/index.js`: - `https-proxy-agent` + `http-proxy-agent` (já em /opt/skymilhas/node_modules) - `PROXY_BRIDGE_PORT = 40520` (env `LIVELO_PROXY_PORT`) - Agents `keepAlive`, `keepAliveMsecs:30000`, `maxSockets:60`, `timeout:60000` - `httpGet` passa `agent` no requestOptions `/opt/skymilhas/scrapers/livelo/service.js`: - `process.on('uncaughtException')` + `unhandledRejection` (só logam) - Express error middleware (retorna `success:false` em vez de 500) - `/health` reporta `cache.emAndamento` (pendingSearches.size) - `HARD_TIMEOUT_MS=90000` Promise.race libera `pendingSearches` Backups `.bak-pre-proxy-1777742095` e `.bak-pre-stress-1777743XXX`. ## Capacidade após reforço - 30 paralelas DIFERENTES: 79s, 27 OK + 3 vazio - 15 cache hits paralelos: 252ms - 50 paralelas iguais (dedup): 11s - Bridge: 0 timeouts, 0 failures, vmHealthy - Throughput buscas únicas: ~22/min (gargalo da API Livelo) - Cache hit: milhares/seg (15-30ms cada) ## Link consulta (formato site oficial) - OW: `/passagens-aereas/trip/{O}/{D}/{depDate}/NA/ADULT/ECONOMY_CLASS/{NATIONAL|INTERNATIONAL}?origin={oi}&destination={di}` - RT: `.../{depDate}/{retDate}/...` - Multi-pax: `.../ADULT,ADULT,CHILD,INFANT/...` - Cabin paths: `ECONOMY_CLASS`, `BUSINESS_CLASS`, `FIRST_CLASS` - Scope `NATIONAL` se origem+destino em `BR_AIRPORTS`, senão `INTERNATIONAL` ## Rollback ```bash sudo mv /opt/skymilhas/scrapers/livelo/index.js.bak-pre-proxy-1777742095 /opt/skymilhas/scrapers/livelo/index.js sudo mv /opt/skymilhas/scrapers/livelo/service.js.bak-pre-proxy-1777742095 /opt/skymilhas/scrapers/livelo/service.js sudo pm2 restart scraper-livelo-pontos ``` ## Smart bridge :40520 (proxy-bridge-vm) `/opt/skymilhas/scrapers/proxy-bridge-vm/index.js`. Tenta VM ADV-22 :8888 (tinyproxy), fallback :40500 (proxy-seller BR). Cooldown 60s após 3 falhas seguidas. Stats em `/stats` (porta 40521).