# Quickstart — Ligbox Watchman (Spec 035)

**Público:** ops_lead, super_admin  
**Host alvo:** VM122 (`10.10.10.122`)

---

## Pré-requisitos

- Repo em `/opt/ligbox-ops-platform` (git pull Forgejo)
- Python 3.11+
- Acesso LAN a VMs 112/114/123/130
- Tópico ntfy criado (ex.: `ligbox-watchman`)

---

## 1. Mitigação imediata (Docker restart)

```bash
cd /opt/ligbox-ops-platform
# Adicionar restart: unless-stopped em api, frontend, worker, redis
docker-compose -f docker-compose.mvp.yml up -d
```

---

## 2. Instalar Watchman (após implementação Fase 1)

```bash
cd /opt/ligbox-ops-platform
sudo ./deploy/watchman/install.sh
sudo cp deploy/watchman/watchman.env.example /etc/ligbox-watchman/env
sudo nano /etc/ligbox-watchman/env   # NTFY_URL, tópico, email
sudo systemctl enable --now ligbox-watchman
```

---

## 3. Verificar

```bash
systemctl status ligbox-watchman
journalctl -u ligbox-watchman -f
cat /var/lib/ligbox-watchman/status.json | python3 -m json.tool
```

---

## 4. Teste de alerta (staging)

```bash
docker stop ligbox-ops-platform_frontend_1
# Esperar ~60s (2× critical 30s) → ntfy DOWN
docker start ligbox-ops-platform_frontend_1
# Esperar ~60s → ntfy RESOLVED
```

---

## Variáveis (`/etc/ligbox-watchman/env`)

```env
WATCHMAN_CATALOG=/opt/ligbox-ops-platform/contracts/stack-services.yaml
WATCHMAN_STATE_DIR=/var/lib/ligbox-watchman
NTFY_URL=https://ntfy.ligbox.com.br
NTFY_TOPIC=ligbox-watchman
NTFY_TOKEN=
ALERT_EMAIL=admin@ligbox.com.br
SMTP_HOST=127.0.0.1
SMTP_PORT=25
FAILURES_BEFORE_ALERT=2
```

---

## Rollback

```bash
sudo systemctl stop ligbox-watchman
sudo systemctl disable ligbox-watchman
```
