Skip to main content

Module unix

Module unix 

Source
Expand description

Unix process backed proc spawning.

UnixProcSpawner launches one OS child process per spawned proc and supervises it through a per-proc UnixProcWorker. Inside the child, a proc-local SpawnActor endpoint hosts the spawned actors. The child joins its spawner over a one-shot token; the worker then links the proc and relays its supervision to the caller.

The actors (boxes) and the messages they exchange, grouped by the proc each runs on. UnixProcSpawner and its per-proc UnixProcWorkers share the spawner proc; the caller’s Supervisor lives on the caller proc (possibly remote); each spawned ActorSpawner runs in its own OS process, a child proc of the spawner proc. Once linked, the caller spawns actors directly on the child through its ActorSpawner endpoint (the SpawnActor arrow) — the spawner’s job is only to create and supervise the proc.

  ┌─────────────┐   SpawnProc        ┌─────────────────┐
  │             │ ─────────────────▶ │ UnixProcSpawner │ ┐
  │             │                    └─────────────────┘ │
  │             │   WorkerCommand             │ spawns    │ spawner proc
  │  Supervisor │ ─────────────────▶ ┌────────▼────────┐ │
  │             │ ◀───────────────── │  UnixProcWorker │ ┘ ◀─ UnixProcExited (reaper)
  │             │   SupervisorEvent  └─────────────────┘   ◀─ KillProc (self)
  │             │                       │          ▲
  │             │              StopProc │          │ token::Joined<UnixProcJoin>
  │             │                       ▼          │ ActorSupervisionEvent
  │             │   SpawnActor       ┌─────────────────┐ ┐ child proc
  │             │ ─────────────────▶ │   ActorSpawner  │ ┘ (child of the
  └─────────────┘   (future)         └─────────────────┘   spawner proc)
    caller proc
  • SpawnProc: the caller asks the spawner to create a proc.
  • WorkerCommand: the caller drives a linked proc (stop, unlink).
  • SupervisorEvent: the worker reports lifecycle to the caller’s supervisor.
  • token::Joined<UnixProcJoin>: the child joins, handing back its gateway address, SpawnActor endpoint, and control port.
  • StopProc: the worker asks the child to drain and stop gracefully.
  • ActorSupervisionEvent: the child forwards a top-level failure to the worker.
  • UnixProcExited: the OS-process reaper task reports the child’s exit status.
  • KillProc: a worker self-message that hard-kills the child when a graceful stop misses the grace period.
  • SpawnActor: after linking, the caller spawns actors directly on the child proc through its ActorSpawner endpoint.

Structs§

StopProc
Graceful stop request sent by the spawner to a child proc’s control endpoint. The child drains and stops its actor-spawn endpoint, which tears the proc down cleanly so the OS process exits with a normal status.
UnixProc
Helper for Unix child processes launched by UnixProcSpawner.
UnixProcCommand
Command used by UnixProcSpawner to launch child procs.
UnixProcJoin
Information exchanged with a Unix child proc when it joins its spawner.
UnixProcSpawner
Unix process backed implementation of SpawnProc.
UnixProcToken
Token used by a Unix child proc to boot and report readiness to its spawner.

Constants§

UNIX_PROC_TOKEN_ENV
Environment variable containing the one-shot token a child proc uses to boot and join its spawner.