Server: basic implementation. Not tested => no python installed; bugfix in ESP (uvicorn on port 8090)
This commit is contained in:
1 parent
3694cdf207
commit
8a51e3d95e
38 files changed
+2442
-21
No files matched your search
@@ -28,7 +28,7 @@ Anything here that contradicts SPEC means SPEC needs an edit, not a workaround.
|
||||
| Firmware | Written, compiles, **never run on hardware**. Known gaps below. |
|
||||
| Device↔server contract | Specified in full (`firmware/API.md`). Nothing implements the server half. |
|
||||
| Data model | Designed (SPEC §3) + §0 additions. No migration written. |
|
||||
| Server | **Nothing exists.** |
|
||||
| Server | Phase 1 skeleton in [`server/`](server/) — config, schema, health, job queue, scheduler, systemd units. **Not yet run against a real PostgreSQL.** |
|
||||
| WebUI | **Nothing exists.** |
|
||||
|
||||
---
|
||||
@@ -75,38 +75,46 @@ SPEC §10 Q3, restated as a radar question. Everything downstream assumes this w
|
||||
|
||||
Target host: the x86 Linux thin client. No containers — packages and systemd units.
|
||||
|
||||
- [ ] Base install: static IP (or DHCP reservation) and **hardcode that address in firmware** — more reliable than mDNS
|
||||
Skeleton written — see [`server/README.md`](server/README.md) to run it, and
|
||||
[`server/deploy/INSTALL.md`](server/deploy/INSTALL.md) to deploy it. What is
|
||||
written vs. what still needs doing on the real host:
|
||||
|
||||
- [x] Python venv layout, FastAPI + Pydantic v2 + SQLAlchemy 2.0 + Alembic — `server/`
|
||||
- [x] systemd units `poorbird-api.service` + `poorbird-worker.service`, `After=postgresql.service`, restart policies, sandboxing
|
||||
- [x] Caddyfile with DNS-01 TLS, the `:8080` plain-HTTP camera listener and the auth-checked image handoff
|
||||
- [x] `poorbird check` — validates config, paths and DB before anything starts
|
||||
- [ ] **Run it against a real PostgreSQL** — nothing here has executed yet; `pytest` and `poorbird check` are the first two commands
|
||||
- [ ] Base install on the thin client: static IP (or DHCP reservation) and **hardcode that address in firmware** — more reliable than mDNS
|
||||
- [ ] PostgreSQL 17 from the distro or PGDG repo; dedicated role + database; **loopback TCP with `scram-sha-256`, not a Unix socket** (see 1.2)
|
||||
- [ ] Python 3.13 venv under `/opt/poorbird`, FastAPI + Pydantic v2 + SQLAlchemy 2.0 + Alembic
|
||||
- [ ] systemd units: `poorbird-api.service`, `poorbird-worker.service`, both `After=postgresql.service` with restart policies
|
||||
- [ ] Caddy as a host package; automatic TLS via **DNS-01** so a LAN-only hostname gets a valid cert with no port forwarding
|
||||
- [ ] Caddy DNS provider plugin build (`caddy add-package …`) and a real hostname
|
||||
- [ ] Tailscale for remote access
|
||||
- [ ] Image store at `/srv/poorbird/images/YYYY/MM/DD/<uuid>.jpg`, thumbs alongside as `_400.webp` (SPEC §3.3)
|
||||
- [ ] Image store at `/srv/poorbird/images/YYYY/MM/DD/<uuid>.jpg`, thumbs alongside as `_400.webp` (SPEC §3.3) — paths configured, writer is Phase 2
|
||||
- [ ] journald log retention capped, disk usage alarmed
|
||||
|
||||
### 1.1 Schema — SPEC §3 plus the §0 additions
|
||||
|
||||
- [ ] Initial Alembic migration covering SPEC §3 verbatim
|
||||
- [ ] `captures.pre_trigger BOOL` — was this frame captured *before* the trigger fired
|
||||
- [ ] `devices.awake BOOL` — reported every heartbeat, so the UI can show command latency honestly
|
||||
- [ ] `devices.reenroll_secret_hash`
|
||||
- [ ] `device_status` time-series table (full column list in SPEC §0)
|
||||
- [ ] `devices` settings surface: `cam_day`, `cam_night` (full OV2640 parameter sets), night window + behaviour, nightlight mode + brightness, battery calibration, `config_version`
|
||||
- [ ] Job queue on Postgres with `FOR UPDATE SKIP LOCKED` — thumbnails, retention, backup, exports. **No Redis.**
|
||||
- [x] Initial Alembic migration covering SPEC §3, guarded by a schema-drift test
|
||||
- [x] `captures.pre_trigger BOOL` — was this frame captured *before* the trigger fired
|
||||
- [x] `devices.awake BOOL` — reported every heartbeat, so the UI can show command latency honestly
|
||||
- [x] `devices.reenroll_secret_hash`
|
||||
- [x] `device_status` time-series table (SPEC §0 columns, plus `raw` JSONB so nothing is lost)
|
||||
- [x] `devices` settings surface — **one JSONB `config` column, not forty**: `GET /config` is ~40 optional keys the firmware merges and clamps, so a column per key means a migration per firmware tunable. Validation moves to a Pydantic model. Promote an individual key to a column only if it ever needs querying across devices.
|
||||
- [x] Job queue on Postgres with `FOR UPDATE SKIP LOCKED` — **No Redis.** Handlers for thumbnails / retention / backup arrive with their phases.
|
||||
- [ ] Seed `taxa` (Phase 3) and the `settings` defaults
|
||||
|
||||
### 1.2 Staying container-ready
|
||||
|
||||
Not building containers now. Just not painting into a corner. Each of these is
|
||||
cheap today and most are the better native choice regardless.
|
||||
|
||||
- [ ] **All config from environment**, via systemd `EnvironmentFile=/etc/poorbird/poorbird.env`. No paths, hosts or secrets baked into code or committed config. That file becomes a compose `.env` unchanged.
|
||||
- [ ] **Postgres over loopback TCP**, not a Unix socket — the one genuinely container-hostile choice, and the only real change from a purely native design
|
||||
- [ ] **All mutable state in a few explicit top-level directories** (`/srv/poorbird/images`, `/srv/poorbird/thumbs`, `/var/lib/poorbird`), never scattered under the app dir. These are the future volume mounts.
|
||||
- [ ] **Log to stdout/stderr.** journald catches it now, a log driver would catch it later. Simpler than app-managed log files either way.
|
||||
- [ ] **Migrations as a standalone idempotent command** (`alembic upgrade head`), run from `ExecStartPre` — never at app import time
|
||||
- [ ] **One env var for the image root**, read by both the app and the Caddy config, since the auth-checked handoff needs them to agree on the path
|
||||
- [ ] **Scheduled jobs run in the worker, not as systemd timers** — decided. APScheduler with a SQLAlchemy jobstore on the existing Postgres. Not primarily for portability: SPEC §3.4 makes *backup schedule + target* and *retention policy* UI-editable server settings, and a UI-editable systemd timer means the app writing unit files and calling `daemon-reload` behind a polkit or sudoers rule. In-app, the schedule is just a settings row. Timers stay the better answer for anything that is **not** UI-configurable — if such a job appears, use one.
|
||||
- [ ] Keep API and worker as separate processes — already the plan, and it maps 1:1 to two services later
|
||||
- [x] **All config from environment**, via systemd `EnvironmentFile=/etc/poorbird/poorbird.env`. No paths, hosts or secrets baked into code or committed config. That file becomes a compose `.env` unchanged.
|
||||
- [x] **Postgres over loopback TCP**, not a Unix socket — the one genuinely container-hostile choice, and the only real change from a purely native design
|
||||
- [x] **All mutable state in a few explicit top-level directories** (`/srv/poorbird/images`, `/srv/poorbird/thumbs`, `/var/lib/poorbird`), never scattered under the app dir. These are the future volume mounts.
|
||||
- [x] **Log to stdout/stderr.** journald catches it now, a log driver would catch it later. Simpler than app-managed log files either way.
|
||||
- [x] **Migrations as a standalone idempotent command** (`poorbird migrate`), run from `ExecStartPre` on the API unit only — never at app import time, and never from two units at once
|
||||
- [x] **One env var for the image root**, read by both the app and the Caddy config, since the auth-checked handoff needs them to agree on the path
|
||||
- [x] **Scheduled jobs run in the worker, not as systemd timers** — decided. APScheduler with a SQLAlchemy jobstore on the existing Postgres. Not primarily for portability: SPEC §3.4 makes *backup schedule + target* and *retention policy* UI-editable server settings, and a UI-editable systemd timer means the app writing unit files and calling `daemon-reload` behind a polkit or sudoers rule. In-app, the schedule is just a settings row. Timers stay the better answer for anything that is **not** UI-configurable — if such a job appears, use one.
|
||||
- [x] Keep API and worker as separate processes — maps 1:1 to two services later
|
||||
|
||||
**Deliberately not doing now:** writing Dockerfiles or a compose file speculatively. That means maintaining two deployment paths to prove a point.
|
||||
|
||||
|
||||
Reference in new issue
Block a user