PRODUCTION RECIPE: one What site on a Linux server with systemd, Caddy in front.

Not run on a Linux server. These files are checked by parsing
(scripts/recipe-check.py) and the configuration by starting run-what on a
development machine. Starting the service under systemd on Linux, real
TLS and hosting are unverified.

FILES
  what.service  systemd unit, installed as /etc/systemd/system/what.service
  Caddyfile     Caddy site, installed as /etc/caddy/Caddyfile
  env.example   the form secret's file, copied to /etc/my-site/env
  what.toml     the server's what.toml: the project's own, with [server]
                set for Caddy (the public HTTPS origin, one proxy hop)

PREREQUISITES (yours to provide; nothing here creates them)
  1. A Linux server with systemd, a domain whose DNS points at it, ports 80
     and 443 open, and Caddy installed (Caddy obtains the certificate).
  2. A run-what binary built for that server. A binary built on macOS does
     not run on Linux. Build it from the What source with
     cargo build --release --bin run-what on the server, or on a Linux
     machine with the same architecture and a C library no newer than the
     server's. Install it as /usr/local/bin/run-what, owned by root, mode
     0755.
  3. A service account that cannot log in and owns only the data, with its
     own group of the same name (Group=what in the unit):
       sudo useradd --system --user-group --home-dir /srv/my-site --shell /usr/sbin/nologin what
  4. The two persistent folders, owned by the account, private, created
     before the service starts (systemd refuses a missing ReadWritePaths):
       sudo install -d -o root -g root -m 0755 /srv/my-site
       sudo install -d -o what -g what -m 0700 /srv/my-site/data /srv/my-site/uploads
     data/ holds the store (data/app.db, with -wal and -shm while running)
     and the sessions database (data/sessions.db); uploads/ holds uploaded
     files. Both folders must persist across restarts and upgrades. A
     backup (L22) holds the store and uploads/ only: sessions are never
     backed up or restored, so after a restore, sign-ins through the site's
     own accounts start again.
  5. The site files in /srv/my-site, owned by root, directories 0755 and
     files 0644, so the service reads them and cannot change them:
     this folder's what.toml as /srv/my-site/what.toml (with your domain),
     site/, static/ and components/. Put data/pages.json (read once, on the
     first start) in on its own, so data/ and uploads/ keep the owner and
     mode from step 4:
       sudo install -o root -g root -m 0644 data/pages.json /srv/my-site/data/pages.json
     Never copy a whole data/ or uploads/ folder over them, and never
     chown or chmod the project recursively. Copy no data/app.db, no
     sessions database and no .env: the server creates its own data, and a
     .env in the project would be loaded and travel with every copy of the
     project.
  6. The secret, outside the project:
       sudo install -d -o root -g root -m 0755 /etc/my-site
       sudo install -o root -g root -m 0600 env.example /etc/my-site/env
       openssl rand -hex 32
     Paste the generated value after WHAT_SERVER_FORM_SECRET= in
     /etc/my-site/env (sudoedit /etc/my-site/env). Left empty, run-what
     refuses to start.
  7. Your domain in two places, the same origin in both: the site address
     in the Caddyfile and allowed_origins in /srv/my-site/what.toml
     ("https://" plus the domain, nothing after it).

START
  The first editor account (there is no built-in one), as the service
  account so its files belong to it, before the first start:
    sudo -u what /usr/local/bin/run-what admin add editor --path /srv/my-site
  Then:
    sudo install -o root -g root -m 0644 what.service /etc/systemd/system/what.service
    sudo systemctl daemon-reload
    sudo systemctl enable --now what
    sudo install -o root -g root -m 0644 Caddyfile /etc/caddy/Caddyfile
    sudo systemctl reload caddy
  Logs: journalctl -u what. For JSON log lines, add WHAT_LOG_FORMAT=json to
  /etc/my-site/env and restart.

WHY EACH SETTING
  --production   no file watching, live reload, developer tools, debug
                 output or detailed error pages; session cookies keep
                 Secure, so the site needs HTTPS (Caddy).
  127.0.0.1      only Caddy, on the same machine, reaches run-what; the
                 plain HTTP port is never public. trusted_proxy_hops = 1 is
                 correct only while this holds.
  allowed_origins  state-changing requests are accepted only from the
                 public HTTPS origin.
  WHAT_SERVER_FORM_SECRET  signs the rules of <form w-validate> forms; with
                 the same secret such a form opened before a restart still
                 submits after it, with a new one it must be reloaded. Forms
                 without w-validate (the course's edit forms) do not depend
                 on it; keep it stable for the w-validate forms you add.
  KillSignal=SIGINT  run-what shuts down cleanly on SIGINT; systemd's
                 default SIGTERM stops it without the clean shutdown.
  ProtectSystem=strict, ReadWritePaths  within the project the service can
                 write only data/ and uploads/; the site files and what.toml
                 stay as you installed them. (PrivateTmp gives it its own
                 writable temporary folder outside the project.)
