File size: 4,418 Bytes
f2f34e4 9d7a35f 483f682 94e6ed4 9d7a35f bc8a823 94e6ed4 b73eed5 5eedbdc b73eed5 483f682 8ab8ff3 483f682 18163dc 483f682 b73eed5 c5085aa bc8a823 c5085aa b73eed5 c5085aa bc8a823 c5085aa b73eed5 c5085aa bc8a823 c5085aa b73eed5 c5085aa bc8a823 c5085aa b73eed5 483f682 c5085aa bc8a823 c5085aa 483f682 c5085aa bc8a823 c5085aa 483f682 c5085aa bc8a823 c5085aa 483f682 c5085aa bc8a823 c5085aa 483f682 b73eed5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# agent/start_repl.py
import sys
import os
import threading
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from init import ensure_db_initialized
from tools.storage import Storage
# Проверка инициализации (вернёт config, если всё ОК)
config = ensure_db_initialized()
storage = Storage()
# ⚙️ Включение/отключение компонентов
ENABLE_REPL = False # 🧠 repl.py
ENABLE_UI = True # 📓 web_ui.py (FastAPI)
ENABLE_MESH = False # 🌐 agent_mesh_listener.py
ENABLE_SYNC = True # 🔄 peer_sync.py
ENABLE_TRANSPORT = False # 📡 transporter.py
ENABLE_CONTROL = False # 🧭 agent_controller.py
ENABLE_CONTAINER = False # 🧱 container_agent.py
ENABLE_ETHICS = False # 🧠 ethics_guard.py
def start_all():
threads = []
if ENABLE_REPL:
if not storage.is_process_alive("REPL", max_delay=180):
def repl():
from repl import start_repl
start_repl()
threads.append(threading.Thread(target=repl, name="REPL"))
else:
print("REPL уже работает по данным heartbeat.")
if ENABLE_UI:
if not storage.is_process_alive("NotebookUI", max_delay=180):
def ui():
from web_ui import start_notebook
start_notebook()
threads.append(threading.Thread(target=ui, name="NotebookUI"))
else:
print("NotebookUI уже работает по данным heartbeat.")
if ENABLE_MESH:
if not storage.is_process_alive("MeshListener", max_delay=180):
def mesh():
from agent_mesh_listener import start_listener
start_listener()
threads.append(threading.Thread(target=mesh, name="MeshListener"))
else:
print("MeshListener уже работает по данным heartbeat.")
if ENABLE_SYNC:
if not storage.is_process_alive("PeerSync", max_delay=180):
def sync():
from peer_sync import start_sync
start_sync()
threads.append(threading.Thread(target=sync, name="PeerSync"))
else:
print("PeerSync уже работает по данным heartbeat.")
if ENABLE_TRANSPORT:
if not storage.is_process_alive("Transporter", max_delay=180):
def transport():
from transporter import start_transporter
start_transporter()
threads.append(threading.Thread(target=transport, name="Transporter"))
else:
print("Transporter уже работает по данным heartbeat.")
if ENABLE_CONTROL:
if not storage.is_process_alive("Controller", max_delay=180):
def control():
from agent_controller import start_controller
start_controller()
threads.append(threading.Thread(target=control, name="Controller"))
else:
print("Controller уже работает по данным heartbeat.")
if ENABLE_CONTAINER:
if not storage.is_process_alive("ContainerAgent", max_delay=180):
def container():
from container_agent import start_container
start_container()
threads.append(threading.Thread(target=container, name="ContainerAgent"))
else:
print("ContainerAgent уже работает по данным heartbeat.")
if ENABLE_ETHICS:
if not storage.is_process_alive("EthicsGuard", max_delay=180):
def ethics():
from ethics_guard import start_ethics_guard
start_ethics_guard()
threads.append(threading.Thread(target=ethics, name="EthicsGuard"))
else:
print("EthicsGuard уже работает по данным heartbeat.")
# Запуск потоков
for thread in threads:
try:
thread.start()
print(f"[✔] Поток {thread.name} запущен.")
except Exception as e:
print(f"[⚠️] Ошибка запуска потока {thread.name}: {e}")
for thread in threads:
thread.join()
if __name__ == "__main__":
print("[*] Инициализация завершена. Запуск потоков...")
start_all()
|