LlamaProcessManager

Manages the lifecycle of a local LLAMA-Server OS process.

Responsibilities:

  • Launching the server process with a caller-provided command line

  • Capturing stdout / stderr on daemon threads

  • Polling the /health endpoint until the server is ready

  • Graceful + forced shutdown

  • Finding a free TCP port

Parameters

log

Logging callback (LogLevel, message).

Constructors

Link copied to clipboard
constructor(log: (CodBi.LogLevel, String) -> Unit)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The running server process, or null if not started.

Functions

Link copied to clipboard
fun findFreePort(preferredPort: Int): Int

Finds a free TCP port starting from preferredPort. Probes upward (up to 20 attempts) until an available port is found. Falls back to an OS-assigned ephemeral port if all probed ports are busy.

Link copied to clipboard

Returns true if the server process is alive.

Link copied to clipboard
fun launchProcess(command: List<String>, workingDir: File, port: Int): Boolean

Launches the LLAMA-Server process and waits for it to become healthy.

Link copied to clipboard

Stops the server process gracefully. Tries destroy() first, then destroyForcibly() after a timeout.