Candil.Engine.Server (Candil v2.1.0)

Copy Markdown View Source

GenServer that supervises a single llama-server OS process.

The OS process itself is owned by Arrea.LongRunning, which gives us for free:

  • Registration in Arrea.Registry under {:candil_engine, model.alias} so other apps can Arrea.LongRunning.state(id) / health(id) / stop(id) without going through Candil.
  • Telemetry events on [:arrea, :long_running, ...] for started / stopped / crashed / data.
  • Automatic port cleanup on crash (Arrea links the port and the GenServer; if the binary dies, Arrea dies, and the link cascade kills this GenServer too).
  • Crash isolation via Arrea.WorkerSupervisor's :one_for_one strategy.

What this GenServer keeps:

  • The Candil-side Candil.Registry registration under the model alias (so Candil.Engine.stop/1, healthy?/1, base_url/1 keep working through the existing API).
  • A cached healthy boolean refreshed by a 5s /health poll (informational; Arrea also runs the probe for telemetry).
  • The terminate/2 cleanup that calls Arrea.LongRunning.stop/1 explicitly when Candil stops the engine normally.

Summary

Functions

Returns a specification to start this module under a supervisor.

Types

state()

@type state() :: %{
  engine: Candil.Engine.t(),
  model: Candil.Model.t(),
  base_url: binary(),
  lr_pid: pid(),
  healthy: boolean()
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.