🛸 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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user