Manage workers from the web UI, persisted in SQLite

Replace the CROSS_PY_WORKERS env list with a DB-backed worker store so agents
can be added/removed (and their online status verified) from the browser.
- db.py: add workers table + list_workers/add_worker/remove_worker.
- workers.py: configured_workers() reads the DB instead of settings.
- app.py: POST /api/workers (add, probes reachability) and
  DELETE /api/workers/<port>/<host>; startup log uses DB worker count.
- UI: Workers card with add form, per-worker live status + OS/CPU, remove.
- settings.py: drop CROSS_PY_WORKERS/_get_json_list; DB is single source.
- README/DESIGN updated to describe UI-managed workers.
This commit is contained in:
Brett Williams
2026-08-30 23:37:31 -05:00
parent 5967b606c7
commit 18d8d2e398
10 changed files with 187 additions and 41 deletions
+15 -12
View File
@@ -80,24 +80,25 @@ source venv/bin/activate
pip install -e .
```
Set the static worker list (JSON array of `host:port`, matching where your agents are
listening) and start it:
Set the port (defaults to `8080`) and start it:
```sh
CROSS_PY_WORKERS='["192.168.1.40:9001","192.168.1.41:9001"]' \
cross-py-controller
CROSS_PY_PORT=8080 cross-py-controller
```
Then open `http://<controller-ip>:8080` in a browser.
Then open `http://<controller-ip>:8080` in a browser and add your agents from the
**Workers** section of the UI (in `host:port` form, e.g. `192.168.1.40:9001`). Each
row shows live status (ready/down) and the agent's OS/CPU/version. Configured workers
persist in the controller's SQLite DB, so they survive restarts — no environment
variables needed after setup.
### Controller environment variables
| Variable | Default | Purpose |
|---|---|---|
| `CROSS_PY_WORKERS` | (none) | JSON array of agent `host:port` strings |
| `CROSS_PY_PORT` | `8080` | HTTP port the controller UI listens on |
| `CROSS_PY_MAX_CONCURRENT` | `1` | Max simultaneous builds (across distinct agents) |
| `CROSS_PY_DATA` | `<repo>/data` | Data dir (jobs DB, uploaded sources) |
| `CROSS_PY_DATA` | `<repo>/data` | Data dir (SQLite jobs + workers DB, uploaded sources) |
| `CROSS_PY_BUILDS` | `<data>/builds` | Dir where finished build artifacts are saved |
| `CROSS_PY_DEBUG` | off | Use Flask dev server instead of waitress |
@@ -105,12 +106,14 @@ Then open `http://<controller-ip>:8080` in a browser.
## Using the UI
1. Open the controller in a browser.
2. Pick the target **OS** and **CPU** (or "any").
3. Either upload a `.zip` of your project (PyInstaller spec + source) or paste a git
1. **Add your agents** in the Workers section (`host:port`). Each shows live status
(ready/down) and OS/CPU once reachable.
2. Open the controller in a browser.
3. Pick the target **OS** and **CPU** (or "any").
4. Either upload a `.zip` of your project (PyInstaller spec + source) or paste a git
`repo_url`.
4. Submit. The job is queued → dispatched to a matching agent → built → artifacts fetched.
5. Watch live per-step progress, then download the built binaries from the job detail.
5. Submit. The job is queued → dispatched to a matching agent → built → artifacts fetched.
6. Watch live per-step progress, then download the built binaries from the job detail.
A submitted project only needs the source plus at least one `*.spec` file; each spec file in
the archive produces a build.