Breaking: with state.dir set, jobs still waiting when the daemon stops or crashes print after the next start, in order and however old, instead of being marked failed or forgotten; a client that resends such jobs must stop. The Docker image sets state.dir, so a container keeps its jobs in /var/lib/uberbringer, and loses them with the container unless a volume is mounted there. The owner decided that jobs survive a restart and that a restart never prints a receipt twice. When state.dir is set, the daemon now opens the SQLite job store there, jobs.db, and the queue restores it before the subscriptions are made and before anything is served, so restored jobs go ahead of new ones and a second daemon on the directory stops before it reads the subscriptions' state. Without state.dir the queue keeps its jobs in memory, as before. The store closes once the queue has stopped. A job's sending mark is synced before its first byte, so one caught mid write reads uncertain after the restart and is never sent again; a job that had not reached the printer prints once. A store that cannot be opened stops the start with an error naming the file, rather than starting empty and forgetting which receipts are in doubt. The unit gains UMask=0077, so the store's files are its user's alone, and says why systemd's 90 s stop timeout is enough; the Dockerfile and docs/docker.md ask for --stop-timeout 40. design.md replaces "The queue lives in memory" with the store, the state machine, the sync policy, store failures, stage 1a's numbers, and that the ARM builds ship the store untested on ARM hardware. install.md and docker.md say how to set aside a store that will not open; configuration.md, api.md, cli.md and ntfy.md say what survives a restart. The license notices gain the driver's modules. TestServeRestart runs the daemon twice on one directory: jobs queued when the first run stops, its printer refusing connections, print in order after the restart, ahead of a new job, and a job seeded in sending between the runs reads uncertain and never reaches the printer. Part of stage 1d of docs/plans/job-store.md (decisions 14 and 15). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
82 lines
3.3 KiB
Markdown
82 lines
3.3 KiB
Markdown
# Installing with install.sh
|
|
|
|
`install.sh` sets up a fresh Debian or Ubuntu host: the latest release, a
|
|
systemd service, and [Caddy](https://caddyserver.com) in front of it for
|
|
HTTPS with an automatic certificate. It does not upgrade a host set up by
|
|
the 0.1 script. For the Docker image, see [docker.md](docker.md); to run
|
|
from source, see [development.md](development.md#running-from-source).
|
|
|
|
```sh
|
|
sudo ./install.sh printer.example.com you@example.com 192.168.1.245
|
|
```
|
|
|
|
The arguments are:
|
|
|
|
1. The server's domain. Its DNS must point at the server, with ports 80 and
|
|
443 free and reachable.
|
|
2. The email address for the certificate account.
|
|
3. The printer's IP address or host name, without a port.
|
|
|
|
To install a given release, v0.2.0 or later:
|
|
|
|
```sh
|
|
sudo UBERBRINGER_VERSION=v0.2.0 ./install.sh <domain> <acme-email> <printer-address>
|
|
```
|
|
|
|
## After installing
|
|
|
|
- The config is `/etc/uberbringer/config.toml`.
|
|
[configuration.md](configuration.md) describes every setting.
|
|
- The first API token is in `/etc/uberbringer/initial-token`: copy it to
|
|
your client, then delete the file. [security.md](security.md#issuing-tokens)
|
|
shows how to issue more.
|
|
- The service may write only to `/var/lib/uberbringer`, where it keeps its
|
|
job store, `jobs.db`, so that waiting jobs print after a restart, and
|
|
where the [ntfy subscriptions](ntfy.md) keep their state. A config the
|
|
script creates sets [`state.dir`](configuration.md#state) to it. Re-runs
|
|
keep the config, so an older config without that setting keeps its jobs
|
|
in memory until you add it:
|
|
|
|
```toml
|
|
[state]
|
|
dir = "/var/lib/uberbringer"
|
|
```
|
|
|
|
- The unit keeps systemd's stop timeout, 90 seconds, so a receipt that is
|
|
being written to the printer when the service stops can finish. If you
|
|
lower it with `systemctl edit`, keep it above `printer.write_timeout`
|
|
plus 10 seconds (40 at the defaults); a stop that kills the write leaves
|
|
the job `uncertain`.
|
|
- Change the systemd unit with `systemctl edit uberbringer`.
|
|
- The install log is `/var/log/uberbringer-install.log`.
|
|
|
|
## Upgrading and changing the config
|
|
|
|
Re-running the script upgrades the install and keeps the config. After
|
|
editing the config, run `systemctl restart uberbringer`. After changing
|
|
`webserver.body_limit`, `bind_ip` or `port`, re-run the script instead: it
|
|
copies them into Caddy's config.
|
|
|
|
## A job store that will not open
|
|
|
|
If `/var/lib/uberbringer/jobs.db` is damaged, or was written by a newer
|
|
version, the service stops at start with an error naming the file
|
|
(`journalctl -u uberbringer`). It does not start with an empty store,
|
|
which would forget the jobs still waiting and which receipts may have
|
|
printed. To set the store aside and start afresh:
|
|
|
|
```sh
|
|
sudo systemctl stop uberbringer
|
|
sudo mkdir -p -m 0700 /var/backups/uberbringer
|
|
sudo sh -c 'mv /var/lib/uberbringer/jobs.db* /var/backups/uberbringer/'
|
|
sudo systemctl reset-failed uberbringer
|
|
sudo systemctl start uberbringer
|
|
```
|
|
|
|
This moves `jobs.db` and its log, `jobs.db-wal`, together; never move or
|
|
delete one without the other. The jobs in the old store are forgotten, so
|
|
check the last receipts on paper against what was sent. The moved files
|
|
hold what those receipts printed: delete them once you no longer need
|
|
them. `reset-failed` matters only once systemd has stopped restarting the
|
|
service after three failed starts in a minute.
|