aiti-updater (Updater)
Updater (aiti-updater)
An upgrade should be a tire change, not a pit stop.
The pi-web host upgrade panel, executed through service-tunnels (the st CLI / daemon): version state, two-phase upgrades, service management. It deliberately does three things — show the version, check again, one upgrade action. Progress and observation stay on the assistant window's own status page; the panel never draws a fake stepper.
Two-phase upgrade
| Phase | What happens | Downtime |
|---|---|---|
| A · prefetch | POST /prefetch downloads / builds the new payload into a staging directory; progress lands in ~/.svc-assistant/prefetch.json and the panel follows /prefetch/events (SSE, event-driven) with cancel by exact pid | none |
| B · install | Launch the assistant window → confirm on the ARMED page → the orchestrator stops the service, commits the staged payload, verifies the port and restarts | sub-second |
Once staging is ready the button becomes "② Install and restart (vX)". Launching is idempotent: an assistant with the same semantics is reused instead of starting a second one. The launch pipeline prefers a transient system unit (sudo -n systemd-run, safe over SSH), falls back to the user manager, then to a plain detached process; candidate addresses are probed again from the browser and only verified-reachable ones are listed.
Service management
- Runtime shape: the process cgroup is the single source of truth — a persistent unit means "service"; a transient/session unit or no unit means "manual".
- Register as service: generate a one-shot register-service config from the running process (launch / env allowlist sampling) and start through the same pipeline.
- Registration preflight: four-way port check (free / self-managed / conflict / bare).
- Service verbs: install / uninstall / start / stop / restart / status / logs / enable / disable; env edits go through
service.action updateenv.
Configuration
<configDir>/updater-settings.json (settings file > env > detected defaults):
| Field | Meaning |
|---|---|
stCli | service-tunnels CLI entry (default ~/workspace/service-tunnels/dist/cli.js) |
upgradeConfig | launch.json-shaped upgrade/service config |
npmCheck | npm version compare { pkgDir, pkgName, registry? } |
upgradeGitDir | repo directory for the git-shaped version compare |
piWebPort | port shown by the panel |
pkgDir | the running install the two-phase update targets |
Dev instances (PI_WEB_DEV_DIST=1) read updater-settings.dev.json — on machines where dev and prod share a data root, a single file would point both instances at each other's services.
Beyond the panel
- Takes over the built-in Update button (DOM path on sandboxes/old hosts; the native branch consumes the
aiti-updater.launchclient service). - Forwards the assistant's "upgrade-done" message as a host toast asking for a refresh.
- Backup channel: during the pi-web self-upgrade stop window, the standalone
stupgrade page (tunnel +?tk=) carries observation and recovery.