# Day to day ## Create a cache As in [the README](../README.md#getting-started), at `https://bldbox.tail09e44.ts.net/` instead of localhost: mint, wire, save the ids, fill. Copy the cookie from a browser running on bldbox: diigo accepts it only from the IP it was issued to (see [issue 1](open-issues.md#-1-how-does-diigo-see-the-cookie-come-from-the-ip-it-was-issued-to)). The public page is then `https://bldbox.tail09e44.ts.net/public/?days=7`, on the tailnet only. ## Logs ```sh journalctl -u diigo-cache.service -f -o cat | jq -Rr 'fromjson? | "\(.timestamp / 1000 | todate) \(.level) \(.message | gsub("\\s*\\n\\s*"; " "))"' ``` `fromjson?` skips lines that aren't JSON: systemd's own ("Started …") and entries from before `structuredLogging`. workerd runs with `structuredLogging`: each entry is one line of JSON, `{timestamp, level, message}`. `message` is the logged object as `console.log` prints it, not JSON: on Cloudflare, Workers Logs indexes the fields of a logged object, so the workers log objects rather than strings. workerd logs the workers' `console.*` output: `{event: "cache", kind, page, outcome}` per page read, `{event: "fill", state, …}` per fill step (a refresh logs `refetchThrough`), `{event: "mint"}`. Ids show only as fingerprints; the cookie never appears. ## State With `DynamicUser=yes`, systemd keeps the state in `/var/lib/private/diigo-cache/` (`/var/lib/diigo-cache` is a symlink to it), mode 0700, owned by a uid that exists only while the service runs: | Dir | Holds | Secret? | | :--- | :--- | :--- | | `cache/diigo-cache-DiigoCache/` | private caches: every bookmark | yes | | `cache/diigo-cache-PublicCache/` | public caches and the username index | no | | `webapp/webapp-WebAppDo/` | webapp instances: the diigo cookie | yes, a credential | Each Durable Object is one `.sqlite`. Read one with the service stopped, or copy it first: `sudo sqlite3 -readonly .tables`. ## Backups The private caches are refillable from diigo; the cookie can be re-minted. What's lost with the state is the binding from the ids people saved to these objects. Backups hold the cookie, so treat them as secret. ```sh sudo systemctl stop diigo-cache.socket diigo-cache.service # the socket would restart it sudo tar -C /var/lib/private -czf diigo-cache-$(date +%F).tgz diigo-cache sudo systemctl start diigo-cache.socket ``` No backup is scheduled (see [open issue 6](open-issues.md#-6-how-is-state-backed-up)). ## The cookie expires When fills log `{event: "fill", state: "failed"}` with a diigo auth error, mint a fresh webapp instance and wire a new cache. A wired cache refuses a different webapp id (`setup` in [cache.ts](../src/cache.ts)) (see [open issue 7](open-issues.md#-7-how-does-a-cache-get-a-fresh-cookie)).