WhisperServerManager

Manages the full lifecycle of a local whisper-server instance: binary download, FFmpeg provisioning, process launch, health-checking, resource monitoring, and shutdown.

Extracted from Whisper.kt so the servlet class only handles configuration and request routing.

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

GPU backend detected at initialization.

Link copied to clipboard

true when ffmpeg is available, enabling the --convert flag.

Link copied to clipboard

Captures the first fatal error during background initialization, if any.

Link copied to clipboard

The TCP port the running server listens on. 0 means no server is running.

Link copied to clipboard

true once the whisper-server is healthy and accepting requests.

Functions

Link copied to clipboard

Estimated seconds the client should wait before retrying.

Link copied to clipboard

Returns a human-readable reason if resource thresholds are exceeded, or null if available.

Link copied to clipboard

Marks the server as ready without starting a local process (external API mode).

Link copied to clipboard
fun shutdown()

Stops the resource monitor, kills the server process, and resets readiness state.

Link copied to clipboard
fun startAsync(preferredPort: Int, whisperRelease: String, whisperReleaseBaseUrl: String, modelUrl: String, modelsDir: File, binDir: File, whisperDir: File, noGpu: Boolean, threadCount: Int?, maxRAMPercent: Double, maxComputePercent: Double, onReady: (port: Int) -> Unit)

Starts background initialization: downloads the whisper-server binary and model, ensures ffmpeg, launches the server, and starts the resource monitor.