106 lines
2.3 KiB
Markdown
106 lines
2.3 KiB
Markdown
|
|
---
|
||
|
|
okf: "0.1"
|
||
|
|
type: runbook
|
||
|
|
visibility: private
|
||
|
|
status: active
|
||
|
|
updated: 2026-05-27
|
||
|
|
links:
|
||
|
|
- ../services/planner-agent.md
|
||
|
|
---
|
||
|
|
|
||
|
|
# planner-agent — deploy, uruchamianie, testy
|
||
|
|
|
||
|
|
## Deployment na SOLARIA
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# 1. Przygotuj .env na solaria
|
||
|
|
ssh oskar@100.100.231.104
|
||
|
|
mkdir -p /opt/homelab/config/planner-agent
|
||
|
|
cat > /opt/homelab/config/planner-agent/.env << 'EOF'
|
||
|
|
OLLAMA_HOST=http://host-gateway:11434
|
||
|
|
OLLAMA_MODEL=qwen2.5-coder:14b
|
||
|
|
REDIS_URL=redis://100.108.208.3:6379
|
||
|
|
NODE_NAME=solaria
|
||
|
|
COOLDOWN_SECONDS=300
|
||
|
|
RUNTIME_PATH=/opt/homelab
|
||
|
|
EOF
|
||
|
|
|
||
|
|
# 2. Deploy przez standardowy skrypt (z SATURN)
|
||
|
|
scripts/deploy/deploy.sh --service planner-agent
|
||
|
|
|
||
|
|
# 3. Weryfikacja
|
||
|
|
docker ps --filter name=planner-agent
|
||
|
|
docker logs planner-agent --tail 30
|
||
|
|
ls -la /opt/homelab/state/planner-agent.heartbeat
|
||
|
|
```
|
||
|
|
|
||
|
|
> **Uwaga:** stage `verify` w deploy.sh może failować bezpośrednio po starcie
|
||
|
|
> (race condition — heartbeat jest pisany co ~5 s). Kontener jest zdrowy gdy
|
||
|
|
> `docker ps` pokazuje `(healthy)`.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Uruchamianie lokalne (bez Dockera)
|
||
|
|
|
||
|
|
```bash
|
||
|
|
cd services/planner-agent
|
||
|
|
|
||
|
|
# Zainstaluj zależności
|
||
|
|
pip install -r requirements.txt
|
||
|
|
|
||
|
|
# Wyeksportuj zmienne (lub stwórz .env i użyj `export $(cat .env | xargs)`)
|
||
|
|
export REDIS_URL=redis://localhost:6379
|
||
|
|
export OLLAMA_HOST=http://localhost:11434
|
||
|
|
export OLLAMA_MODEL=qwen2.5:7b
|
||
|
|
export NODE_NAME=dev-local
|
||
|
|
export RUNTIME_PATH=/tmp/homelab-dev
|
||
|
|
export COOLDOWN_SECONDS=10
|
||
|
|
|
||
|
|
# Uruchom
|
||
|
|
python src/planner.py
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Testowanie
|
||
|
|
|
||
|
|
### Testy jednostkowe
|
||
|
|
|
||
|
|
```bash
|
||
|
|
cd services/planner-agent
|
||
|
|
pip install -r requirements.txt pytest pytest-asyncio
|
||
|
|
pytest tests/ -v
|
||
|
|
# 49 testów planner + 34 testy llm_router
|
||
|
|
```
|
||
|
|
|
||
|
|
### Ręczny end-to-end test przez Redis
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Opublikuj sztuczne zdarzenie unhealthy na kanale health_events
|
||
|
|
redis-cli -h 100.108.208.3 PUBLISH health_events '{
|
||
|
|
"type": "service_unhealthy",
|
||
|
|
"node": "piha",
|
||
|
|
"service": "mosquitto",
|
||
|
|
"severity": "error",
|
||
|
|
"payload": {"exit_code": 1, "reason": "OOMKilled"},
|
||
|
|
"timestamp": "2026-05-27T20:00:00Z"
|
||
|
|
}'
|
||
|
|
|
||
|
|
# Obserwuj logi planera
|
||
|
|
docker logs planner-agent -f
|
||
|
|
|
||
|
|
# Sprawdź czy propozycja trafiła do pending
|
||
|
|
ls /opt/homelab/actions/pending/
|
||
|
|
cat /opt/homelab/actions/pending/plan-piha-mosquitto-*.json
|
||
|
|
```
|
||
|
|
|
||
|
|
### Śledzenie metryk LLM
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Subskrybuj metryki routera w czasie rzeczywistym
|
||
|
|
redis-cli -h 100.108.208.3 SUBSCRIBE llm_router_metrics
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|