diigo binds the session cookie to the IP it was issued to, so a Cloudflare deployment can't use a cookie minted in the browser. Run diigo-cache and webapp in one workerd on bldbox instead. The flake bundles each worker with wrangler's dry run, so the modules match what `wrangler deploy` ships, and generates the workerd config from the bundles. workerd comes from nixpkgs' wrangler, the only packaged one. A smoke check serves the home page and mints a webapp instance, which covers the WEBAPP binding and Durable Object storage. The service is a system unit with DynamicUser, so the webapp state holding the cookie isn't readable by processes running as the user. It listens on loopback behind tailscale serve: HTTPS, which PasswordCredential needs, at the tailnet name only. Operator docs in doc/; unsettled points recorded as IBIS issues. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
82 lines
3.8 KiB
Markdown
82 lines
3.8 KiB
Markdown
# Install, upgrade, roll back
|
|
|
|
Everything below runs on bldbox. Neither unit has been run under the system manager yet; the flake's smoke check runs the same build under workerd directly.
|
|
|
|
## Once: tailnet HTTPS
|
|
|
|
In the [Tailscale admin console DNS page](https://login.tailscale.com/admin/dns), enable MagicDNS (on) and **HTTPS Certificates** (off as of 2026-10-14: `tailscale status --json | jq .CertDomains` is `null`). HTTPS matters: the "save to password manager" button uses `PasswordCredential`, which browsers offer only in a secure context.
|
|
|
|
## Build and check
|
|
|
|
```sh
|
|
cd ~/oros-bots/capsite/diigo-cache
|
|
nix flake check # builds, then serves the home page and mints a webapp instance
|
|
out=$(nix build --no-link --print-out-paths .#)
|
|
nix/probe-unit.sh "$out" # serves it under the unit's syscall filter: "probe: ok"
|
|
```
|
|
|
|
The probe catches what the smoke check can't: the nix sandbox has no systemd, so it doesn't apply the unit's `SystemCallFilter`. The flake only sees files git tracks: `git add` new files before building.
|
|
|
|
## Install
|
|
|
|
The service runs whatever `/nix/var/nix/profiles/diigo-cache` points at, so the profile is also the GC root and the rollback history.
|
|
|
|
nix-env is spelled out in full because sudo's `secure_path` leaves out nix's profile.
|
|
|
|
```sh
|
|
sudo /nix/var/nix/profiles/default/bin/nix-env -p /nix/var/nix/profiles/diigo-cache --set "$out"
|
|
sudo systemctl link /nix/var/nix/profiles/diigo-cache/lib/systemd/system/diigo-cache.{socket,service}
|
|
sudo systemctl enable --now diigo-cache.socket
|
|
sudo tailscale serve --bg --https=443 http://127.0.0.1:8790
|
|
```
|
|
|
|
`tailscale serve --bg` persists across reboots in tailscaled's state; `tailscale serve status` shows it.
|
|
|
|
## Verify
|
|
|
|
```sh
|
|
curl -sf https://bldbox.tail09e44.ts.net/ | grep -c _connect # 1+; first request starts workerd
|
|
systemctl status diigo-cache.service
|
|
```
|
|
|
|
On a 502, make sure `tailscale serve` finds something on 8790: `curl -sI http://127.0.0.1:8790/`. (The cache also answers 502 when it can't load a page from diigo; its body then says `could not load page`.) If workerd crashes on start, systemd stops retrying, then fails the socket too (`Result: service-start-limit-hit` in `systemctl status diigo-cache.socket`). After fixing the cause:
|
|
|
|
```sh
|
|
sudo systemctl reset-failed diigo-cache.socket diigo-cache.service
|
|
sudo systemctl start diigo-cache.socket
|
|
```
|
|
|
|
From another tailnet device, open `https://bldbox.tail09e44.ts.net/`. From off the tailnet, the name doesn't resolve and `100.89.146.23` doesn't route.
|
|
|
|
## Upgrade
|
|
|
|
```sh
|
|
out=$(nix build --no-link --print-out-paths .#)
|
|
nix/probe-unit.sh "$out"
|
|
sudo /nix/var/nix/profiles/default/bin/nix-env -p /nix/var/nix/profiles/diigo-cache --set "$out"
|
|
sudo systemctl daemon-reload # in case the units changed
|
|
sudo systemctl restart diigo-cache.service
|
|
```
|
|
|
|
Durable Object state outlives the code: an upgrade whose schema change existing state can't read is a breaking change (see [capsite AGENTS.md](../../AGENTS.md#durable-state-be-loud-and-conservative-about-breaking-changes)). Back up first ([operate](operate.md#backups)).
|
|
|
|
## Roll back
|
|
|
|
```sh
|
|
sudo /nix/var/nix/profiles/default/bin/nix-env -p /nix/var/nix/profiles/diigo-cache --list-generations
|
|
sudo /nix/var/nix/profiles/default/bin/nix-env -p /nix/var/nix/profiles/diigo-cache --rollback
|
|
sudo systemctl restart diigo-cache.service
|
|
```
|
|
|
|
## Update nixpkgs
|
|
|
|
`nix flake update` moves wrangler, and with it workerd. The flake names workerd's version (`version` in [flake.nix](../flake.nix)); if nixpkgs' wrangler bundles a different one, the build fails with `no workerd <version>`. Set it to the bundled version, which must be no older than the workers' `compatibility_date`.
|
|
|
|
## Remove
|
|
|
|
```sh
|
|
sudo tailscale serve --https=443 off
|
|
sudo systemctl disable --now diigo-cache.socket diigo-cache.service
|
|
sudo rm /nix/var/nix/profiles/diigo-cache* # state in /var/lib/private/diigo-cache stays
|
|
```
|