Skip to content

Ollama server readiness check uses a fixed sleep instead of a health poll #61

@Raze3478

Description

@Raze3478

In install-core.ps1, after starting the Ollama server process for model
import, the script waits with a hardcoded delay:

$ServerProcess = Start-Process -FilePath "...\ollama.exe" -ArgumentList "serve" -WindowStyle Hidden -PassThru
Start-Sleep -Seconds 5

A 5-second sleep is not a readiness check. On slower drives (USB 2.0, older
spinning SSDs) Ollama takes longer to bind and the subsequent ollama create
calls fail silently because the server is not yet accepting connections.
The current error handling swallows the failure:

$null = & "...\ollama.exe" create $m.Local -f "Modelfile-$($m.Local)" 2>&1

So the model appears to import successfully, but nothing was actually registered.

Expected behaviour
The script should poll the Ollama API endpoint (http://127.0.0.1:11434) in
a retry loop with a timeout before proceeding to model import, rather than
assuming the server is ready after a fixed interval.

Proposed fix
Replace Start-Sleep -Seconds 5 with a polling loop, for example:

$maxWait = 30
$elapsed = 0
do {
    Start-Sleep -Seconds 1
    $elapsed++
    try {
        $resp = Invoke-WebRequest -Uri "http://127.0.0.1:11434" -UseBasicParsing -TimeoutSec 1 -ErrorAction SilentlyContinue
        if ($resp.StatusCode -eq 200) { break }
    } catch {}
} while ($elapsed -lt $maxWait)

if ($elapsed -ge $maxWait) {
    Write-Host "ERROR: Ollama server did not become ready in time." -ForegroundColor Red
    exit 1
}

This makes the import step deterministic regardless of drive speed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions