Files
karung-counting-feedmill-se…/docs/deployment.md
T
andrew 0467e0ce68
ci / smoke (push) Canceled after 0s
docs: add CHANGELOG.md, sync all guides with config.yaml migration
- CHANGELOG.md (Keep-a-Changelog, dated entries from git history)
- README: production pipeline framing, config table, layout, flags, changelog link
- configuration.md: legacy env overrides, zones geometry-only, archive paths
- scripts.md: current flags, correct archive/ paths, tracked vs ignored weights
- deployment.md: config.yaml in sync list, model_mode location, /api/model-modes
- models.md + architecture.md: config.yaml pointers, deprecated src/config.py
2026-09-17 12:04:56 +07:00

56 lines
2.8 KiB
Markdown

# Deployment (Jetson)
Repo: `https://git.proit.id/andrew/karung-counting-feedmill-semarang`
(`git remote set-url origin <url>` after the ervan → andrew transfer).
## Systemd services
| Unit | Runs | After |
|---|---|---|
| `karung-counter.service` | `/usr/bin/python3 predict.py` (cwd `/home/jetson/karung`, `QT_QPA_PLATFORM=offscreen`) | `network.target` |
| `karung-counter-dashboard.service` | `/usr/bin/python3 counter_dashboard.py` | `network.target` + counter |
| `mediamtx.service` | MediaMTX restream (see `zones.json:external_stream_url`) | — |
Both app units: `Restart=always`, `RestartSec=5`, load `EnvironmentFile=/home/jetson/karung/.env`.
```bash
sudo systemctl enable --now karung-counter karung-counter-dashboard
sudo systemctl restart karung-counter karung-counter-dashboard
systemctl status karung-counter karung-counter-dashboard --no-pager
```
## Deploy flow (`deploy_to_jetson.py`)
Paramiko sync of `templates/{operator,monitoring,base}.html`, `counter_dashboard.py`,
`predict.py`, `config.yaml`, `.env` **plus `models/*.engine`** (v4-best,
yolo11n-sack+box, best, truck-detector, model_karung_truk) →
`192.168.192.96:/home/jetson/karung/` (creates remote `models/` if missing,
skips missing local files), then restarts both services and checks status +
ports (5000/5721). Run from the dev machine. `.pt`/`.onnx` stay local-only
(dev/export).
## TensorRT export
On the Jetson (needs CUDA): `python3 export_model.py models/<name>.pt` exports to
FP16 `.engine` next to the `.pt` (default: karung-dimuat seg model). Production
loads `.engine` only — see `models/modelREADME.md` for which weights each mode uses.
## Runtime data files
- SQLite `jetson_counter.db`: `batches(counting_date, batch_number, camera_name,
object_label, count, start/end_time)`, `daily_summaries(...)`.
- `current_batch.json` (crash recovery), `batch_mode.json` (manual/auto batch
mode only — the model mode lives in `config.yaml`),
`batch_history_folder/batch_<ts>.json` + `hasil_perhitungan.json` (per-batch reports).
- Live frame: `/dev/shm/jetson-counter/live_frame.jpg` (written every 2nd frame,
consumed by `/api/live-video` MJPEG).
- Helpers: `check_jetson_db.py` (root); retired ops scripts in `archive/`
(`backup.py`, `dump_db.py`, `migrate_jetson_db.py`, `merge_batches_*.py`,
`update_batches.py`, `diagnose_truck_jetson.py`).
## Dashboard (`counter_dashboard.py`)
Pages: `/` + `/monitoring`, `/operator` (manual start/stop, mode switch),
`/history`, `/analytics`. Key APIs: `/api/live-video`, `/api/current-batch`,
`/api/previous-batch`, `/api/batch/{start,stop,mode}`, `/api/model-modes`
(mode list is derived from `config.yaml`, so future modes appear automatically),
`/api/summary`, `/api/daily-data`, `/api/day-detail/<date>`,
`/api/recent-batches`, `/api/available-dates`, `/api/export-daily-csv`,
`/api/export-day-csv/<date>` (CSV + Excel via openpyxl).