add systemd user unit so the dev server starts at boot

This commit is contained in:
Martin Dvořák 2026-09-28 20:50:07 +00:00
commit 174212750b
3 changed files with 78 additions and 3 deletions

View file

@ -249,6 +249,15 @@ list reordering, not free placement. Don't confuse the two.
`localhost:3000` keeps the full dev experience; the LAN/tunnel get a plain,
live-reloading site. Use `npm run dev:next` only if you explicitly want the
raw, unprotected server (never point the tunnel at it).
- The dev server normally runs on this host as a **user** systemd unit
(`~/.config/systemd/user/dvorakmortonxd-dev.service`, kept in-repo at
`deploy/dvorakmortonxd-dev.service`). `Linger=yes` for uid 1000 means it starts
at boot without a login. `systemctl --user restart dvorakmortonxd-dev` reloads
it; logs with `journalctl --user -u dvorakmortonxd-dev -f`. From a bare shell
with no session bus, prefix those with
`XDG_RUNTIME_DIR=/run/user/1000 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus`.
The unit pins `HOSTNAME=0.0.0.0` (the script reads that env var) so the tunnel
can reach :3000, and clears a stale `.next/dev/lock` on start.
- `allowedDevOrigins` (`next.config.ts`) still matters: the tunnel host and any
LAN origin must be listed or Next rejects the HMR WebSocket with a 403 (the
client then never hydrates — SSR only, icons stacked at `(0,0)`, dead
@ -299,9 +308,11 @@ list reordering, not free placement. Don't confuse the two.
## Testing notes
- There is **no test suite**. Verification is `tsc --noEmit`, `eslint`, and
`next build`.
- A dev server may already be running on port 3000; check before starting one.
Two dev servers on this repo collide on `.next/dev/lock`, so stop the old one
(and delete the stale lock) before starting the custom one.
- A dev server may already be running on port 3000 — on this host it is normally
the `dvorakmortonxd-dev` user systemd service, so check
`systemctl --user status dvorakmortonxd-dev` first. Two dev servers on this
repo collide on `.next/dev/lock`; stop the service (or the old process)
before starting the custom server by hand.
- Dev-server guard check: `curl -s -o /dev/null -w '%{http_code}' \
http://localhost:3000/__nextjs_server_status` must be `200` (localhost keeps
debug), while the same path through the LAN IP or `beta.dvorakmortonxd.dev`