Expand description
Long-lived local server (“sidecar”) lifecycle for picoframe apps.
A sidecar is a persistent localhost HTTP server (e.g. a Bun process) spawned once at app startup, so substantial non-Rust business logic runs in-process without per-call subprocess cold-start. This module owns the full lifecycle:
- spawn the bundled binary (Tauri
externalBin, resolved next to the app exe) or a dev command (bun run server.ts) when the compiled binary is absent undertauri dev; - handshake — the child binds an ephemeral
127.0.0.1port and writes a0600{port,token,pid}file we poll; the token is a per-spawn shared secret we generate; - health — poll
GET /health(bearer auth) until ready or timeout; - stream — hold an SSE connection to
GET /eventsand re-emit each progress record as the Tauri event"<event_prefix>/progress"; - supervise — if the child exits unexpectedly and
restartis set, respawn it; - shutdown — kill the child on app exit. (The child also self-exits if it sees the parent pid disappear, covering the SIGKILL case that a parent-side kill cannot.)
Transport is loopback TCP + a shared-secret bearer token rather than a Unix socket, so the same code path works on Windows, macOS and Linux.
Structs§
- Sidecar
- A running, supervised sidecar. Cheaply cloneable (
Arcinside); dropping the last clone kills the child. - Sidecar
Options - Configuration for a supervised sidecar.