This commit is contained in:
2026-10-21 11:53:46 -04:00
parent eb6f6b3f3d
commit 77ec52b053
4 changed files with 336 additions and 16 deletions
+14 -3
View File
@@ -35,7 +35,7 @@ Logged-in players can also join the mailing list.
docker compose up -d --build
```
Open http://localhost:8000. Game data and the mailing list are stored in the `button-data` volume.
Open http://localhost:8000. The SQLite game database and the mailing list are stored in the `button-data` volume. Existing JSON game data in that volume is automatically migrated on the first startup after upgrading.
```sh
docker compose logs -f # view logs
@@ -52,7 +52,17 @@ Requires Python 3.9+. No third-party packages.
python server.py
```
Open http://127.0.0.1:8000. Delete `data.json` to start a new game.
Open http://127.0.0.1:8000. Game state is stored in `data.sqlite3`.
### Migrating existing data
On startup, if the database has no saved game and `data.json` exists, the server automatically imports the countdown, players, password hashes, active sessions, subscription flags, and complete press history in one transaction. Older single-token player records are also supported. No manual conversion or additional dependencies are needed.
The JSON file is left untouched as a backup. Once the database contains a game, it is authoritative: subsequent restarts never re-import the JSON file. Invalid source data causes startup to fail rather than silently starting a new game; fix the source and restart to retry. The mailing-list CSV is unchanged.
Custom `BUTTON_DATA_FILE` paths continue to locate legacy JSON data; by default, the SQLite database is created alongside it with a `.sqlite3` suffix. `BUTTON_DATABASE_FILE` can override the database path. Docker keeps both paths under `/data`, so existing named volumes migrate automatically.
To start a new game, stop the server and delete the SQLite database **and remove or move the legacy JSON backup**; leaving the JSON file in place would import the old game again.
## Configuration
@@ -63,7 +73,8 @@ Set via environment variables (in Docker, add them under `environment:` in `comp
| `BUTTON_DURATION_SECONDS` | `86400` | Countdown length. Zones scale with it. |
| `BUTTON_HOST` | `127.0.0.1` (`0.0.0.0` in Docker) | Address to listen on. |
| `BUTTON_PORT` | `8000` | Port to listen on. |
| `BUTTON_DATA_FILE` | `data.json` | Game state file. |
| `BUTTON_DATA_FILE` | `data.json` | Legacy JSON file to import if no saved SQLite game exists. |
| `BUTTON_DATABASE_FILE` | `data.sqlite3` | SQLite game database; defaults to `BUTTON_DATA_FILE` with a `.sqlite3` suffix. |
| `BUTTON_MAILING_LIST_FILE` | `mailing_list.csv` | Mailing list file. |
Tip: `BUTTON_DURATION_SECONDS=60` makes for quick testing.