Files
microdao-daarion/docs/NODE2_GUARDIAN_QUICKSTART.md
Apple 80123fd1be feat(node2): Add scripts and docs for NODE2 guardian setup
- Add start-node2-guardian.sh script for easy launch
- Add setup-node2-agents.sh to update node_id for NODE2 agents
- Add NODE2_GUARDIAN_QUICKSTART.md with detailed instructions
- Update agents node_id to node-2-macbook-m4max
2025-12-02 06:59:48 -08:00

5.1 KiB
Raw Blame History

Швидкий старт Node Guardian для НОДА2 (MacBook)

Крок 1: Перевірка доступності сервісів

# Перевірити чи Router доступний
curl http://localhost:9102/health

# Перевірити чи Swapper доступний
curl http://localhost:8890/health

Якщо обидва повертають {"status":"healthy"}, продовжуйте.

Крок 2: Встановлення залежностей

cd /Users/apple/github-projects/microdao-daarion
pip3 install httpx

Крок 3: Запуск Node Guardian

Варіант А: Одноразовий запуск (для тестування)

cd /Users/apple/github-projects/microdao-daarion
./scripts/start-node2-guardian.sh

Варіант Б: Запуск у фоновому режимі (рекомендовано)

cd /Users/apple/github-projects/microdao-daarion

# Запустити в фоні
nohup ./scripts/start-node2-guardian.sh > /tmp/node-guardian.log 2>&1 &

# Перевірити логи
tail -f /tmp/node-guardian.log

Варіант В: Запуск через launchd (macOS)

Створіть файл ~/Library/LaunchAgents/com.daarion.node-guardian.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.daarion.node-guardian</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/python3</string>
        <string>/Users/apple/github-projects/microdao-daarion/scripts/node-guardian-loop.py</string>
        <string>--node-id</string>
        <string>node-2-macbook-m4max</string>
        <string>--node-name</string>
        <string>НОДА2</string>
        <string>--city-url</string>
        <string>https://daarion.space/api/city</string>
        <string>--environment</string>
        <string>development</string>
        <string>--roles</string>
        <string>gpu,ai_runtime</string>
        <string>--hostname</string>
        <string>$(hostname)</string>
        <string>--interval</string>
        <string>60</string>
    </array>
    <key>EnvironmentVariables</key>
    <dict>
        <key>NODE_SWAPPER_URL</key>
        <string>http://localhost:8890</string>
        <key>NODE_ROUTER_URL</key>
        <string>http://localhost:9102</string>
    </dict>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>StandardOutPath</key>
    <string>/tmp/node-guardian.log</string>
    <key>StandardErrorPath</key>
    <string>/tmp/node-guardian-error.log</string>
</dict>
</plist>

Завантажити:

launchctl load ~/Library/LaunchAgents/com.daarion.node-guardian.plist
launchctl start com.daarion.node-guardian

Перевірити статус:

launchctl list | grep node-guardian

Крок 4: Перевірка роботи

Перевірити логи:

# Якщо запущено через nohup
tail -f /tmp/node-guardian.log

# Якщо через launchd
tail -f /tmp/node-guardian.log /tmp/node-guardian-error.log

Перевірити в БД (на сервері):

ssh root@144.76.224.179 "docker exec daarion-postgres psql -U postgres -d daarion -c \"SELECT node_id, swapper_healthy, swapper_models_total, router_healthy, last_heartbeat FROM node_cache WHERE node_id = 'node-2-macbook-m4max';\""

Перевірити в UI:

Відкрийте https://daarion.space/nodes/node/node-2-macbook-m4max та перевірте:

  • Swapper Service показує моделі
  • DAGI Router показує статус "Up"
  • Агенти відображаються в списку

Troubleshooting

Guardian не запускається

  1. Перевірте чи Python 3 встановлений:

    python3 --version
    
  2. Перевірте чи httpx встановлений:

    python3 -c "import httpx; print('OK')"
    
  3. Перевірте чи сервіси доступні:

    curl http://localhost:9102/health
    curl http://localhost:8890/health
    

Guardian не оновлює метрики

  1. Перевірте з'єднання з city-service:

    curl -v https://daarion.space/api/city/health
    
  2. Перевірте логи на помилки:

    tail -50 /tmp/node-guardian.log | grep -i error
    
  3. Перевірте чи node_id правильний:

    # В логах має бути: Node ID: node-2-macbook-m4max
    

Агенти не відображаються

  1. Перевірте чи агенти мають правильний node_id:

    ssh root@144.76.224.179 "docker exec daarion-postgres psql -U postgres -d daarion -c \"SELECT id, display_name, node_id FROM agents WHERE node_id = 'node-2-macbook-m4max';\""
    
  2. Якщо потрібно оновити node_id для агентів:

    ./scripts/setup-node2-agents.sh