← back to Norma
agents/instagram-agent/RECOVERY.md
26 lines
# Norma instagram-agent — ops / recovery
- **pm2 name:** `norma-instagram` · **port:** `127.0.0.1:9810` · runs in **simulation mode** until `IG_USER_ID` + `IG_ACCESS_TOKEN` are set.
- **Auth:** Basic auth on every route except `/health`. Creds from `.env` (`AUTH_USERNAME`/`AUTH_PASSWORD`), fleet-standard `admin` / `DW2024!`. `.env` is gitignored — if it's missing, the password silently defaults to **empty string** and `admin`/`DW2024!` will be rejected 403. Recreate `.env` if that happens.
- **Surfaces:** read-only dashboard at `GET /` (behind auth); JSON API `/api/status`, `/api/audit?limit=N`, `/api/cron/status`, `POST /api/cron/{start,stop}`, `POST /api/skill/{reel,story}`; `GET /health` (no auth). Control skill: `instagram-account-manager`.
## Dependency-recovery gotcha (READ THIS)
This agent's own `node_modules/` contains **only `dotenv`**. Everything else
(express, helmet, node-cron, pg, …) resolves from the **shared** base:
`~/Projects/Norma/agents/shared/node_modules/`.
So if the agent crash-loops on `Cannot find module '<x>'`:
- `x` is `dotenv` → `npm install` **here** (`agents/instagram-agent/`).
- `x` is anything else (express/helmet/etc.) → `npm install` in **`agents/shared/`**, NOT here.
`pm2 save` persists *what* to start, not the ability to start — if deps vanish,
pm2 + fleet-keepalive will crash-loop then silently back off (no alert). If the
agent shows `errored` in `pm2 ls`, check `pm2 logs norma-instagram --err` for a
`MODULE_NOT_FOUND` and reinstall in the correct directory per above.
## Reboot durability
In the pm2 resurrect dump (`pm2 save` done) + watched every 60s by
`com.steve.fleet-keepalive` (restarts on crash / 5xx / dead port; treats the
401 auth gate as healthy). **Follow-up worth doing:** add `norma-instagram` to
the `dw-uptime-probe` watchlist so a silent backoff raises an alert.