Replace ntfy.state_dir with a top-level [state] dir
Security / Vulnerability check (push) Successful in 45s
Test / Lint and test (push) Successful in 2m1s

The job store is to keep its database in the directory that holds the
ntfy subscriptions' state files, so the directory moves to a section
of its own: [state] dir, or UBERBRINGER_STATE_DIR, in place of
[ntfy] state_dir. For now only the subscriptions use it. It still has
no default and is still required with a subscription, and the checks
at start name state.dir in their errors.

install.sh writes [state] dir into new configs, and the Docker image
sets UBERBRINGER_STATE_DIR. ntfy.state_dir has never been in a
release, so its CHANGELOG entry changes in place and there is no
fallback: a config that still sets it fails to load with an unknown
key until the line moves to [state].

The image itself was not built, since the workstation has no Docker.

Part of stage 1b of docs/plans/job-store.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
57_WolveandClaude Opus 5.5 committed 2026-12-01 12:21:29 -06:00
1 parent f0b5bf020e
commit 66531e7314
16 files changed
+92 -68

No files matched your search

+10 -7
View File
@@ -13,7 +13,7 @@ shows every setting with its default: copy it to `config.toml` to start.
- [Settings](#settings): [webserver](#webserver), [api](#api),
[printer](#printer), [format](#format), [ntfy](#ntfy),
[ntfy subscriptions](#ntfy-subscriptions), [queue](#queue),
[images](#images), [sentry](#sentry), [log](#log)
[state](#state), [images](#images), [sentry](#sentry), [log](#log)
- [Logs](#logs)
## Loading
@@ -121,10 +121,6 @@ These settings shape the [notification cards](api.md#notification-cards)
of the `notify` and `ntfy` modules and of the [ntfy subscriptions](ntfy.md),
and their [digests](api.md#digests).
| Key | Default | Meaning |
|-----|---------|---------|
| `state_dir` | none | The directory the ntfy subscriptions keep their state in, one `ntfy-<name>.json` file each, readable by the daemon's user only. Required with a subscription. `install.sh` and the Docker image set it to `/var/lib/uberbringer` |
`[ntfy.format]`:
| Key | Default | Meaning |
@@ -143,8 +139,9 @@ tags, at most 16 characters each, and `""` hides a tag: `backup = "[B]"`,
### ntfy subscriptions
Each `[[ntfy.subscriptions]]` table is one connection to one ntfy server,
for one or more topics. They are set in the file only.
[ntfy.md](ntfy.md) shows an example and how a subscription behaves.
for one or more topics. They are set in the file only, and need
[`state.dir`](#state). [ntfy.md](ntfy.md) shows an example and how a
subscription behaves.
| Key | Default | Meaning |
|-----|---------|---------|
@@ -178,6 +175,12 @@ Quiet hours are off unless the subscription has a
| `size` | `100` | Jobs that may wait to print; more get `503` `queue_full` |
| `history` | `1000` | Finished jobs whose status is kept; an older job's ID answers `404` `job_not_found` |
### state
| Key | Default | Meaning |
|-----|---------|---------|
| `dir` | none | The directory the [ntfy subscriptions](#ntfy-subscriptions) keep their state in, one `ntfy-<name>.json` file each, readable by the daemon's user only. Required with a subscription. `install.sh` and the Docker image set it to `/var/lib/uberbringer` |
### images
| Key | Default | Meaning |
+6 -6
View File
@@ -367,7 +367,7 @@ client ─HTTPS─▶ Caddy ─▶ server ── validate ──▶ printqueue (
deliberately left out. A message queued but not yet printed when the
daemon stops is lost, as any waiting job is: the queue stays in
memory, because ESC/POS cannot say what printed.
- State is one JSON file per subscription in `ntfy.state_dir`, written
- State is one JSON file per subscription in `state.dir`, written
atomically (temporary file, fsync, rename), mode 0600 since held
messages carry titles. A change a restart must see, such as a message
printed, held or left out, is written within a second, and so is the
@@ -377,7 +377,7 @@ client ─HTTPS─▶ Caddy ─▶ server ── validate ──▶ printqueue (
day per subscription, which wears an SD card. A saved cursor that is
behind costs only a longer replay after a crash, and the saved IDs
drop the messages it sends again. A damaged
file means a fresh start with a warning. `state_dir` has no default,
file means a fresh start with a warning. `state.dir` has no default,
since the daemon also runs on Windows; `install.sh` writes the unit's
`StateDirectory`, `/var/lib/uberbringer`, and the image sets the same
path.
@@ -445,10 +445,10 @@ before anything is built. They come in this order.
the owner accepted every proposed default, 2026-12-01).
- Jobs survive a restart in SQLite, through `modernc.org/sqlite` and
`database/sql`, not GORM: WAL mode, one connection, exclusive
locking. `jobs.db` lives in `[state] dir`, which replaces
`ntfy.state_dir` and keeps the ntfy state files too; empty keeps the
queue in memory. modernc's exact `modernc.org/libc` is the one
exception to "latest stable", held by a gate check.
locking. `jobs.db` lives in `[state] dir`, beside the ntfy state
files; empty keeps the queue in memory. modernc's exact
`modernc.org/libc` is the one exception to "latest stable", held by
a gate check.
- A job has one delivery per printer, each with its own state. A
delivery's `sending` mark is synced before its first byte, and one
found in `sending` at start ends `uncertain`, a new terminal status,
+1 -1
View File
@@ -54,7 +54,7 @@ alerting better than restarting the container.
## ntfy subscriptions
[ntfy subscriptions](ntfy.md) keep their state in `/var/lib/uberbringer`,
which the image sets as `ntfy.state_dir`. Mount a volume there: without one
which the image sets as `state.dir`. Mount a volume there: without one
the state lives in the container, and a new container, after a pull or an
upgrade, forgets what was printed and what was held.
+2 -2
View File
@@ -32,8 +32,8 @@ sudo UBERBRINGER_VERSION=v0.2.0 ./install.sh <domain> <acme-email> <printer-addr
shows how to issue more.
- The service may write only to `/var/lib/uberbringer`, where the
[ntfy subscriptions](ntfy.md) keep their state. A config the script
creates sets `ntfy.state_dir` to it; add that line to an older config
before adding a subscription.
creates sets [`state.dir`](configuration.md#state) to it; add that
setting to an older config before adding a subscription.
- Change the systemd unit with `systemctl edit uberbringer`.
- The install log is `/var/log/uberbringer-install.log`.
+4 -4
View File
@@ -22,8 +22,8 @@ lists every key, and [ntfy](configuration.md#ntfy) the settings that shape
the cards.
```toml
[ntfy]
state_dir = "/var/lib/uberbringer"
[state]
dir = "/var/lib/uberbringer"
[[ntfy.subscriptions]]
name = "home"
@@ -36,7 +36,7 @@ the cards.
end = "07:00"
```
`install.sh` and the Docker image set `state_dir` already. In Docker, mount
`install.sh` and the Docker image set `state.dir` already. In Docker, mount
a volume for the state and the token file next to the config, as
[docker.md](docker.md#ntfy-subscriptions) shows.
@@ -86,7 +86,7 @@ a volume for the state and the token file next to the config, as
first message of a sequence prints plain, even when its publisher named
the sequence.
- **State.** The cursor, the IDs, the budget and the held messages are in
`<state_dir>/ntfy-<name>.json`, written through a temporary file and a
`<state.dir>/ntfy-<name>.json`, written through a temporary file and a
rename, so a crash leaves the old file or the new one. It is written
within a second of a message being printed, held or left out, at most
every 10 minutes when only keepalives have moved the cursor, and at
+3 -1
View File
@@ -1,6 +1,6 @@
# Plan: persistent job store and image previews
Status: **planned; stage 1a's measurements are done (Investigation findings), and nothing is built.** The owner accepted every proposed default on 2026-12-01 (Decisions), and design.md's Planned next item 1 records them. Each stage runs in its own session, briefed from its section: stage 1a follows decisions 1-3, stage 1b decision 4, stage 1c decisions 5-12, stage 1d decisions 13-15, phase 2 decision 16, phase 2b decisions 17 and 18, phase 3 decision 19 and phase 4 decision 20; phase 5 holds decisions 21-23. Phases 3a-3c need nothing from phases 1 and 2, so they can come first if the owner wants previews sooner. Phase 2b needs phase 1 but not phase 2, so it can come before phase 2. Every check on the live printer needs the owner's OK.
Status: **in progress; stage 1a's measurements are done (Investigation findings), and so is stage 1b's `[state] dir`. The store itself is not built.** The owner accepted every proposed default on 2026-12-01 (Decisions), and design.md's Planned next item 1 records them. Each stage runs in its own session, briefed from its section: stage 1a follows decisions 1-3, stage 1b decision 4, stage 1c decisions 5-12, stage 1d decisions 13-15, phase 2 decision 16, phase 2b decisions 17 and 18, phase 3 decision 19 and phase 4 decision 20; phase 5 holds decisions 21-23. Phases 3a-3c need nothing from phases 1 and 2, so they can come first if the owner wants previews sooner. Phase 2b needs phase 1 but not phase 2, so it can come before phase 2. Every check on the live printer needs the owner's OK.
## Decisions (owner, 2026-11-30)
@@ -623,6 +623,8 @@ On leil-test-1, otherwise idle, since the device counters include every process'
### Stage 1b: `[state] dir`
Done on 2026-12-01.
**Goal.** `[state] dir` replaces `ntfy.state_dir` (decision 4). Nothing else changes: the directory is still used only by ntfy subscriptions.
**Work.**