Spaces:
Runtime error
Runtime error
metadata
title: 9router
emoji: π»
colorFrom: red
colorTo: green
sdk: docker
pinned: false
9router on Hugging Face Spaces
Clones decolua/9router at build, runs it
on port 7860, and persists the SQLite store (/app/data/db/data.sqlite) to a
private HF Dataset repo so rebuilds/restarts don't wipe routing history.
Files
Dockerfileβ Node 20 base, build toolchain, pluspython3+huggingface_hub+sqlite3CLI for bucket syncstart.shβ entrypoint wrapper: pulls latest snapshot from the Dataset repo, spawns background sync loop, thenexec npm run startbackup.shβ invoked every$SYNC_INTERVALseconds:sqlite3 .backupβ clear volatile request/usage history by default β upload compact SQLite to Dataset repo (safe even while the app holds a write lock)
One-time setup on HF
- Create a private Dataset repo, e.g.
hank-jay/9router-storage - In this Space β Settings β Variables and secrets, add:
HF_TOKEN(secret) β write-scoped token with access to the DatasetHF_DATA_REPO(variable, optional) β defaults tohank-jay/9router-storageSYNC_INTERVAL(variable, optional) β backup cadence in seconds, defaults to600BACKUP_MODE(variable, optional) βsettingsby default; usefullonly if you intentionally want request/usage history persisted
- Factory rebuild the Space
Caveats
- Data loss window =
SYNC_INTERVAL(default 10 min). Tighten if writes are critical. - Container shutdown grace on HF is short (~10s); rely on the periodic loop, not a
SIGTERMflush. - If
HF_TOKENis missing, the Space still boots but warns and runs ephemerally β handy for one-off tests, dangerous for prod.