🛸 Fase 1.5 completa: AtomicDrones con visibilidad en Bitácora Web

Bugs corregidos (12): B1-B12 — crashes, tipos, métodos, logger
Ejecutor reescrito: evento web → heartbeat 30s → cierre automático
copiloto.rb y novato.rb deprecados → redirigen a dron lanzar
Plan P009 v3.2 — Fase 1.5 100%% completa
This commit is contained in:
Ricardo Monla
2026-04-09 10:12:04 -03:00
parent fb8c8eefe5
commit 6d7394b22e
9 changed files with 415 additions and 147 deletions
+7 -2
View File
@@ -6,6 +6,9 @@
require_relative 'base'
require_relative '../../db/core/dron_db'
require_relative 'ejecutor'
require 'json'
require 'time'
module Dron
class Sanador
@@ -24,7 +27,8 @@ module Dron
fallidos.each do |dron|
espera = BACKOFF_BASE * (2 ** dron['reintentos'].to_i)
tiempo_desde_fallo = Time.now - dron['completed_at']
completed_at = dron['completed_at'].is_a?(String) ? Time.parse(dron['completed_at']) : dron['completed_at']
tiempo_desde_fallo = Time.now - completed_at
if tiempo_desde_fallo < espera
Base.logger.debug("#{dron['dron_id']} en backoff (#{tiempo_desde_fallo.round}s/#{espera}s)")
@@ -38,7 +42,8 @@ module Dron
else
Base.logger.info("🩹 Re-intentando #{dron['dron_id']} (intento #{dron['reintentos'].to_i + 1}/#{MAX_REINTENTOS})")
ADN::DB::DronDB.incrementar_reintentos(dron['dron_id'])
resultado = Dron::Ejecutor.lanzar(cmd: dron['cmd'], nota: "Reintento: #{dron.dig('metadata', 'nota')}", flujo_id: dron['flujo_id'])
meta = dron['metadata'].is_a?(String) ? (JSON.parse(dron['metadata']) rescue {}) : (dron['metadata'] || {})
resultado = Dron::Ejecutor.lanzar(cmd: dron['cmd'], nota: "Reintento: #{meta['nota']}", flujo_id: dron['flujo_id'])
reintentados += 1 if resultado[:exit_code] == 0
notificar_fallo_persistente(dron) if dron['reintentos'].to_i >= MAX_REINTENTOS && resultado[:exit_code] != 0
end