Manages the optional sidecar OTP application.
At startup SidecarManager checks whether a sidecar directory is configured
(Config.sidecar!/0). When it exists on disk, it:
- Runs
mix deps.getandmix compilesynchronously (fast-fail on error). - Spawns the sidecar as a long-lived OS process via erlexec using:
elixir --sname planck_sidecar --cookie <cookie> -S mix run --no-haltThe following env var is injected so the sidecar can connect back:PLANCK_HEADLESS_NODE—Node.self()stringified
- Monitors node connections. When the sidecar's Erlang node connects
(name must begin with
"planck_sidecar"),SidecarManagerfetches the tool list via RPC and stores it inResourceStore. - On node-down or OS-process exit, clears tools from
ResourceStore.
Progress events
Subscribe with subscribe/0 to receive messages on the "planck:sidecar"
PubSub topic. Events are one of:
{:building, sidecar_dir}— runningmix deps.get/mix compile{:starting, sidecar_dir}— OS process spawned, waiting for node{:connected, node}— sidecar node is up and tools are loaded{:disconnected, node}— sidecar node went down, tools cleared{:exited, reason}— OS process exited unexpectedly{:error, step, reason}— build/startup step failed
Summary
Functions
Returns a specification to start this module under a supervisor.
Return the connected sidecar node name, or nil if not connected.
Start the SidecarManager under its supervisor.
Return the current lifecycle status.
Subscribe the calling process to sidecar lifecycle events on planck:sidecar.
Unsubscribe the calling process from sidecar lifecycle events.
Types
@type state() :: %{ sidecar_dir: Path.t() | nil, sidecar_node: atom() | nil, os_pid: pos_integer() | nil, status: status() }
@type status() :: :idle | :building | :starting | :connected | :failed
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec node() :: atom() | nil
Return the connected sidecar node name, or nil if not connected.
@spec start_link(keyword()) :: GenServer.on_start()
Start the SidecarManager under its supervisor.
@spec status() :: status()
Return the current lifecycle status.
@spec subscribe() :: :ok | {:error, term()}
Subscribe the calling process to sidecar lifecycle events on planck:sidecar.
@spec unsubscribe() :: :ok
Unsubscribe the calling process from sidecar lifecycle events.